[][src]Crate hash_hasher

A std::hash::Hasher which is designed to work with already-hashed or hash-like data.

The provided hasher does minimal work under the assumption that the input data is already suitable for use as a key in a HashSet or HashMap.

As well as the performance benefit, it also causes HashSets or HashMaps to become somewhat deterministic. Given two equal HashSets or HashMaps containing more than a single element, iterating them will yield the elements in differing orders. By using a hash_hasher::HashedSet or hash_hasher::HashedMap, then if the same data is inserted and/or removed in the same order, iterating the collection will yield a consistent order.


Since new() and with_capacity() aren't available for HashSets or HashMaps using custom hashers, the available constructors are default(), with_hasher() and with_capacity_and_hasher().

Using default()

use hash_hasher::HashedMap;

let mut map = HashedMap::default();
assert!(map.insert(0, "zero").is_none());

Using with_capacity_and_hasher()

use hash_hasher::{HashBuildHasher, HashedSet};

let mut set = HashedSet::with_capacity_and_hasher(100, HashBuildHasher::default());



A hasher which does minimal work to create the required u64 output under the assumption that the input is already a hash digest or otherwise already suitable for use as a key in a HashSet or HashMap.

Type Definitions


Alias for a BuildHasherDefault<HashHasher>.


Alias for a std::collections::HashMap<K, V, HashBuildHasher>.


Alias for a std::collections::HashSet<K, HashBuildHasher>.