macro_rules! hashset {
() => { ... };
( $( $elem:expr ),* ) => { ... };
}Expand description
Just like vec!, but for std::collections::HashSet.
This macro uses count_args! to preallocate the exact amount of memory
needed, so it’s more efficient than simply iteratively inserting.
#[macro_use] extern crate colmac;
use std::collections::HashSet;
// create an empty one
let empty: HashSet<u64> = hashset![];
assert_eq!(0, empty.len());
// literal initialization
let mut set_a = HashSet::new();
set_a.insert(123);
set_a.insert(456);
let set_b = hashset!(123, 456);
assert_eq!(set_a, set_b);