Macro defaultmap::defaulthashmap [−][src]
macro_rules! defaulthashmap { (@single $($x:tt)*) => { ... }; (@count $($rest:expr),*) => { ... }; (@hashmap $($key:expr => $value:expr),*) => { ... }; ($($key:expr => $value:expr,)+) => { ... }; ($($key:expr => $value:expr),*) => { ... }; ($default:expr$(, $key:expr => $value:expr)+ ,) => { ... }; ($default:expr$(, $key:expr => $value:expr)*) => { ... }; }
The defaulthashmap!
macro can be used to easily initialize a DefaultHashMap
in the
following ways:
// An empty map with the default as default let _: DefaultHashMap<i32, i32> = defaulthashmap!{}; // An empty map with a specified default let _: DefaultHashMap<i32, i32> = defaulthashmap!{5}; // A prefilled map with the default as the default let _: DefaultHashMap<i32, i32> = defaulthashmap!{ 1 => 10, 5 => 20, 6 => 30, }; // A prefilled map with a custom default let _: DefaultHashMap<i32, i32> = defaulthashmap!{ 5, 1 => 10, 5 => 20, 6 => 30, };