[][src]Macro iter_comprehensions::comprehension

macro_rules! comprehension {
    ($($rest:tt)*) => { ... };
}

A comprehension for constructing an iterator.

This macro generates a sequence of elements (i.e. an Iterator) using generating sequences and conditional filters. The iterator receives a tuple consisting of the variables in the range expressions.

Example

use iter_comprehensions::comprehension;
let mut result = vec![];
for (i,j) in comprehension!(i in 0..5, j in i+1..5, (j + i) % 2 == 0) {
    result.push((i,j));
}
assert_eq!(result, vec![(0, 2), (0, 4), (1, 3), (2, 4)]);