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
Source§impl<T: Clone + FastHash> Clone for RandomState<T>
impl<T: Clone + FastHash> Clone for RandomState<T>
Source§fn clone(&self) -> RandomState<T>
fn clone(&self) -> RandomState<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto 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> 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