Trait sp_std::hash::BuildHasher 1.7.0[−][src]
A trait for creating instances of Hasher
.
A BuildHasher
is typically used (e.g., by HashMap
) to create
Hasher
s for each key such that they are hashed independently of one
another, since Hasher
s contain state.
For each instance of BuildHasher
, the Hasher
s created by
build_hasher
should be identical. That is, if the same stream of bytes
is fed into each hasher, the same output will also be generated.
Examples
use std::collections::hash_map::RandomState; use std::hash::{BuildHasher, Hasher}; let s = RandomState::new(); let mut hasher_1 = s.build_hasher(); let mut hasher_2 = s.build_hasher(); hasher_1.write_u32(8128); hasher_2.write_u32(8128); assert_eq!(hasher_1.finish(), hasher_2.finish());
Associated Types
Loading content...Required methods
pub fn build_hasher(&self) -> Self::Hasher
[src]
Implementations on Foreign Types
impl BuildHasher for RandomState
[src]
type Hasher = DefaultHasher
pub fn build_hasher(&self) -> DefaultHasher
[src]
Implementors
impl<H> BuildHasher for BuildHasherDefault<H> where
H: Default + Hasher,
[src]
H: Default + Hasher,