Expand description
Macros for container literals with specific type.
use lit2::*;
let map = hashmap!{
"a" => 1,
"b" => 2,
};
let set = set!{1, 2, 3};
The lit2 crate uses =>
syntax to separate the key and value for the
mapping macros. It is also possible to use the :
separator, but the keys cannot
be expressions.
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.
Macros§
- btreemap
- Create a BTreeMap from a list of key-value pairs
- btreeset
- Create a BTreeSet from a list of elements.
- convert_
args - Macro that converts the keys or key-value pairs passed to another lit2
macro. The default conversion is to use the
Into
trait, if no custom conversion is passed. - dict
- Alias of “map!”. Create a HashMap from a list of key-value pairs
- hashmap
- Create a HashMap from a list of key-value pairs
- hashmap_
ex - Create a HashMap with
specific type
from a list of key-value pairs - hashset
- Create a HashSet from a list of elements.
- map
- A slightly more concise version of “hashmap!” for the concision-minded. Create a HashMap from a list of key-value pairs
- set
- Alias of “hashset!”. Create a HashSet from a list of elements.