macro_rules! map {
( $(( $k:expr, $v:expr )),* $(,)?) => { ... };
( $( $k:expr => $v:expr ),* $(,)?) => { ... };
}Expand description
Create a new map collection and insert key-value pairs.
Example with tuple syntax:
let m = map!((1, 2), (3, 4));Example with arrow syntax:
let m = map!(1 => 2, 3 => 4);Example with multiple lines and tuple syntax:
let m = map!(
(1, 2),
(3, 4),
);Example with multiple lines and arrow syntax:
let m = map!(
1 => 2,
3 => 4,
);Equivalent Rust standard code:
let mut m = HashMap::new();
m.insert(1, 2);
m.insert(3, 4);