[][src]Macro iter_comprehensions::map

macro_rules! map {
    ($e:expr; $($rest:tt)*) => { ... };
    ($($rest:tt)*) => { ... };
}

A map comprehension.

A sequence of generating expressions and boolean conditions for generating a sequence of values. The two possible macro calls

map!(EXPR; i1 in RANGE1, COND2, ..., ik in RANGEk)
map!(i1 in RANGE1, COND2, ..., ik in RANGEk, EXPR)

is roughly the same as

comprehensions!(i1 in RANGE1, COND2, ..., ik in RANGEk).map(|(i1, i2, ..., ik)| EXPR)

Example

use iter_comprehensions::map;
let mut it = map!(4*i + j; i in 0..5, j in 0..5, i < j);
assert_eq!(it.next(), Some(1));
assert_eq!(it.next(), Some(2));
assert_eq!(it.next(), Some(3));
assert_eq!(it.next(), Some(4));
assert_eq!(it.next(), Some(6));
assert_eq!(it.next(), Some(7));
assert_eq!(it.next(), Some(8));
assert_eq!(it.next(), Some(11));
assert_eq!(it.next(), Some(12));
assert_eq!(it.next(), Some(16));
assert_eq!(it.next(), None);