pub struct RandomState<T: FastHash> { /* private fields */ }Expand description
RandomState provides the default state for HashMap or HashSet types.
A particular instance RandomState will create the same instances of
Hasher, but the hashers created by two different RandomState
instances are unlikely to produce the same result for the same values.
use std::collections::HashMap;
use fasthash::RandomState;
use fasthash::city::Hash64;
let s = RandomState::<Hash64>::new();
let mut map = HashMap::with_hasher(s);
assert_eq!(map.insert(37, "a"), None);
assert_eq!(map.is_empty(), false);
map.insert(37, "b");
assert_eq!(map.insert(37, "c"), Some("b"));
assert_eq!(map[&37], "c");Implementations§
Trait Implementations§
Source§impl<T: FastHash> BuildHasher for RandomState<T>
impl<T: FastHash> BuildHasher for RandomState<T>
Source§fn build_hasher(&self) -> Self::Hasher
fn build_hasher(&self) -> Self::Hasher
Creates a new hasher. Read more
Auto Trait Implementations§
impl<T> Freeze for RandomState<T>
impl<T> RefUnwindSafe for RandomState<T>where
T: RefUnwindSafe,
impl<T> Send for RandomState<T>where
T: Send,
impl<T> Sync for RandomState<T>where
T: Sync,
impl<T> Unpin for RandomState<T>where
T: Unpin,
impl<T> UnsafeUnpin for RandomState<T>
impl<T> UnwindSafe for RandomState<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more