32-bit hashing algorithms
Because 32-bit architectures are a thing (e.g. ARM Cortex-M) and you don’t want your hashing function to pull in a bunch of slow 64-bit compiler intrinsics (software implementations of 64-bit operations).
This crate extends
core::hash with a 32-bit version of
Hasher, which extends
core::hash::Hasher. It requires that the hasher only performs 32-bit operations when computing
the hash, and adds
finish32 to get the hasher’s result as a
u32. The standard
method should just zero-extend this result.
Since it extends
Hasher can be used with any type which implements the
This crate also adds a version of
BuildHasherDefault with a const constructor, to work around
core version’s lack of one.
This crate provides implementations of the following 32-bit hashing algorithms:
In generic code, the trait bound
H: core::hash::Hasher accepts both 64-bit hashers like
std::collections::hash_map::DefaultHasher; and 32-bit hashers like the ones defined in this
The trait bound
H: hash32::Hasher is more restrictive as it only accepts 32-bit hashers.
BuildHasherDefault<H> type implements the
core::hash::BuildHasher trait so it can
construct both 32-bit and 64-bit hashers. To constrain the type to only produce 32-bit hasher
you can add the trait bound
This crate is guaranteed to compile on latest stable Rust. It might compile on older versions but that may change in any new patch release.
32-bit Fowler-Noll-Vo hasher
32-bit MurmurHash3 hasher