maplit 1.0.2

Collection “literal” macros for HashMap, HashSet, BTreeMap, and BTreeSet.

Macros for container literals with specific type.

#[macro_use] extern crate maplit;

# fn main() {
let map = hashmap!{
"a" => 1,
"b" => 2,
# }

The maplit crate uses => syntax to separate the key and value for the mapping macros. (It was not possible to use : as separator due to syntactic restrictions in regular macro_rules! macros.)

Note that rust macros are flexible in which brackets you use for the invocation. You can use them as hashmap!{} or hashmap![] or hashmap!().

Generic container macros already exist elsewhere, so those are not provided here at the moment.