macro_rules! hashmap {
() => { ... };
($($key:expr => $value:expr,)+) => { ... };
($($key:expr => $value:expr),*) => { ... };
}Expand description
Generates the code to initialize a HashMap.
The macro can be followed by parentheses or square brackets.
ยงExample
let days = hashmap![0 => "Monday", 1 => "Tuesday", 2 => "Wednesday"];
// => HashMap::from([(0, "Monday"), (1, "Tuesday"), (2, "Wednesday"), ])
assert_eq!(days, std::collections::HashMap::from([(0, "Monday"), (1, "Tuesday"), (2, "Wednesday")]));