Flatten nested range loops

#1

I’m sorry if I’m missing something obvious but what’s the right way to flatten nested loops? For example, I want to flatten:

for i in 0..10 {
    for j in 0..10 {
         for k in 0..10 {
             // ...
         }
    }
}

Into something like this:

for (i, j, k) in ??? {
    // ...
}
1 Like
#2

https://docs.rs/itertools/0.8.0/itertools/macro.iproduct.html

5 Likes
#3

Thanks! That’s exactly what I wanted.

1 Like