std_macro_extensions/hash_map/
macro.rs

1/// Creates a new hash map instance.
2///
3/// # Arguments
4///
5/// - `expr` - The key-value pairs to initialize the hash map.
6///
7/// # Returns
8///
9/// - `HashMap<K, V>` - A new hash map containing the given key-value pairs.
10#[macro_export]
11macro_rules! hash_map {
12    () => {
13        std::collections::HashMap::new()
14    };
15    ($($key:expr => $val:expr),*) => {{
16        let mut map = std::collections::HashMap::new();
17        $( map.insert($key, $val); )*
18        map
19    }};
20}