Macro rustcomp::set_comp

source ·
macro_rules! set_comp {
    ($($t:tt)*) => { ... };
}
Expand description

Convenience macro that wraps iter_comp! and returns a HashSet containing the results.

Example

let matrix = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]];
let s = set_comp![for row in &matrix; for col in row => *col, if col % 2 == 0];
// is equivalent to:
let it = iter_comp!(for row in matrix; for col in row => col, if col % 2 == 0).collect::<HashSet<_>>();
assert_eq!(s, it);