Struct fhash::RandomState
source · pub struct RandomState { /* private fields */ }Expand description
State used for the random hashing algorithm in HashMap and HashSet.
RandomState introduces randomness into the hashing process to mitigate certain types
of hash collision attacks, enhancing the security and resilience of the data structures.
It is designed to make it harder for attackers to predict hash values and exploit
vulnerabilities in the hash function.
Example
use hashbrown::HashMap;
use fhash::RandomState;
// Create a HashMap using RandomState as the hasher
let mut map: HashMap<i32, &str, RandomState> = HashMap::default();
// Inserting values into the HashMap
map.insert(1, "apple");
map.insert(2, "banana");
// Retrieve values from the HashMap
assert_eq!(map.get(&1), Some(&"apple"));
assert_eq!(map.get(&2), Some(&"banana"));Trait Implementations§
source§impl BuildHasher for RandomState
impl BuildHasher for RandomState
source§fn build_hasher(&self) -> FHasher
fn build_hasher(&self) -> FHasher
Builds a new FHasher using the current RandomState’s state.
source§impl Default for RandomState
impl Default for RandomState
Auto Trait Implementations§
impl RefUnwindSafe for RandomState
impl Send for RandomState
impl Sync for RandomState
impl Unpin for RandomState
impl UnwindSafe for RandomState
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