[−][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 HashSet
s or HashMap
s to become somewhat
deterministic. Given two equal HashSet
s or HashMap
s containing more than a single element,
iterating them will yield the elements in differing orders. By using a
hash_hasher::HashSet
or hash_hasher::HashMap
, then
if the same data is inserted and/or removed in the same order, iterating the collection will
yield a consistent order.
Examples
Since new()
and with_capacity()
aren't available for HashSet
s or HashMap
s 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()); assert!(set.insert(0));
Structs
HashHasher | A hasher which does minimal work to create the required |
Type Definitions
HashBuildHasher | Alias for a |
HashedMap | Alias for a |
HashedSet | Alias for a |