lit2 1.0.9

Collection helper libraries and “literal” macros for HashMap, HashSet, BTreeMap, and BTreeSet.
Documentation
  • Coverage
  • 100%
    10 out of 10 items documented10 out of 10 items with examples
  • Size
  • Source code size: 30.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 551.74 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • willtennien/lit2
    4 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • willtennien

Macros for container literals with specific type.

use lit2::*;

# fn main() {
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.