Macro itertools::iproduct [] [src]

macro_rules! iproduct {
    (@flatten $I:expr,) => { ... };
    (@flatten $I:expr, $J:expr, $($K:expr,)*) => { ... };
    ($I:expr) => { ... };
    ($I:expr, $J:expr) => { ... };
    ($I:expr, $J:expr, $($K:expr),+) => { ... };
}

Create an iterator over the “cartesian product” of iterators.

Iterator element type is like (A, B, ..., E) if formed from iterators (I, J, ..., M) with element types I::Item = A, J::Item = B, etc.

#[macro_use] extern crate itertools;
// Iterate over the coordinates of a 4 x 4 x 4 grid
// from (0, 0, 0), (0, 0, 1), .., (0, 1, 0), (0, 1, 1), .. etc until (3, 3, 3)
for (i, j, k) in iproduct!(0..4, 0..4, 0..4) {
   // ..
}

Note: To enable the macros in this crate, use the #[macro_use] attribute when importing the crate:

#[macro_use] extern crate itertools;