pub struct RapidRandomState { /* private fields */ }
Expand description
A std::collections::hash_map::RandomState compatible hasher that initializes the RapidHasher algorithm with a random seed.
Note this is not sufficient to prevent HashDoS attacks. The rapidhash algorithm is not proven to be resistant, and the seed used is not wide enough.
§Example
use std::collections::HashMap;
use std::hash::Hasher;
use rapidhash::RapidRandomState;
let mut map = HashMap::with_hasher(RapidRandomState::default());
map.insert(42, "the answer");
Implementations§
Source§impl RapidRandomState
impl RapidRandomState
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new random state with a random seed.
With the rand
feature enabled, this will use [rand::random] to initialise the seed.
Without rand
but with the std
feature enabled, this will use crate::rapidrng_time to
initialise the seed.
Trait Implementations§
Source§impl BuildHasher for RapidRandomState
impl BuildHasher for RapidRandomState
Source§impl Clone for RapidRandomState
impl Clone for RapidRandomState
Source§fn clone(&self) -> RapidRandomState
fn clone(&self) -> RapidRandomState
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 moreSource§impl Default for RapidRandomState
impl Default for RapidRandomState
Source§impl PartialEq for RapidRandomState
impl PartialEq for RapidRandomState
impl Copy for RapidRandomState
impl Eq for RapidRandomState
impl StructuralPartialEq for RapidRandomState
Auto Trait Implementations§
impl Freeze for RapidRandomState
impl RefUnwindSafe for RapidRandomState
impl Send for RapidRandomState
impl Sync for RapidRandomState
impl Unpin for RapidRandomState
impl UnwindSafe for RapidRandomState
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