How to elegantly permutate two vectors?


I have two vectors:

    let attributes = ["acousticness",
    let prefixs = ["min_", "max_", "target_"];

I want to get the permutations of this two vectors, so I do it with two iter():

for attribute in attributes {
    for prefix in prefixs {
        let param = prefix.to_owned() + attribute;

Yes, it works. But I just wonder is there another elegant solution for my request ?


Check out iproduct or cartesian_product from the itertools crate.

for (attribute, prefix) in iproduct!(attributes, prefixs) {
    /* ... */


Note that this is not a permutation, it is a (direct) product. This should help with searching for alternative implementations.


sounds great, thanks for your suggestin


get it, it seems it’s my misunderstanding