Macro hash_map
macro_rules! hash_map {
() => { ... };
( $( $key:expr => $value:expr ),* $(,)? ) => { ... };
}
Creates a HashMap containing the arguments.
hash_map! allows specifying the entries that make
up the HashMap where the key and value are separated by a =>.
The entries are separated by commas with a trailing comma being allowed.
It is semantically equivalent to using repeated HashMap::insert
on a newly created hashmap.
hash_map! will attempt to avoid repeated reallocations by
using HashMap::with_capacity.
Examples
use hash_map;
let map = hash_map! ;
assert_eq!;
assert_eq!;
assert!;
And with a trailing comma
use hash_map;
let map = hash_map! ;
assert_eq!;
The key and value are moved into the HashMap.