[−][src]Macro mapcomp::hashsetc
Hash Set Comprehension
Creates a HashSet
from the contents of the comprehension. It is
analogous to Python's set comprehension.
Python code:
matrix = [[3, 8, 7], [9, 5, 3], [4, 5, 6]]
members = {n for row in matrix for n in row}
Rust equivalent code:
let matrix = [[3, 8, 7], [9, 5, 3], [4, 5, 6]]; let members = hashsetc!{n; for row in &matrix; for n in row}; for n in &[3, 8, 7, 9, 5, 4, 6] { assert!(members.contains(n)); }