[][src]Macro iter_comprehensions::vec

macro_rules! vec {
    ($e:expr; $i:ident in $range:expr) => { ... };
    ($e:expr; $i:ident in $range:expr, $($rest:tt)*) => { ... };
    ($($rest:tt)*) => { ... };
}

Extension of vec! with comprehensions.

This is a short form for map!(...).collect::<Vec<_>>().

For convencience the vec! macro also supports the syntax of the std::vec!, i.e. vec![0, 1, 2] and vec![x; 5].

Example

use iter_comprehensions::vec;
assert_eq!(vec!(4*i + j; i in 0..5, j in 0..5, i < j),
           std::vec![1, 2, 3, 4, 6, 7, 8, 11, 12, 16]);