pub type HashMap<K, V> = HashMap<K, V, BuildHasherDefault<XxHash64>>;
Expand description
Alias of std::collections::HashMap
with RandomState
replaced
by a deterministic default hasher XxHash64
. Determinism is important during composition
rendering for reproducibility with seeds.
Unfortunately, with a different hasher, some of the convenience constructors such as
HashMap::new
and
HashMap::from
are lost. Here are some suggestions however:
// To get a new empty HashMap
let map: HashMap<String, String> = HashMap::default();
assert!(map.is_empty());
// To initialize with an array
let map = [("key1", "val1"), ("key2", "val2")].into_iter().collect::<HashMap<_, _>>();
assert_eq!(map.get("key1"), Some(&"val1"));
assert_eq!(map.get("key2"), Some(&"val2"));
Aliased Typeยง
pub struct HashMap<K, V> { /* private fields */ }