pub struct Seed(/* private fields */);
Expand description
Generate hash seeds
It base on the same workflow from std::collections::RandomState
Historically this function did not cache keys from the OS and instead simply always called
rand::thread_rng().gen()
twice. In #31356 it was discovered, however, that because we re-seed the thread-local RNG from the OS periodically that this can cause excessive slowdown when many hash maps are created on a thread. To solve this performance trap we cache the first set of randomly generated keys per-thread.
Later in #36481 it was discovered that exposing a deterministic iteration order allows a form of DOS attack. To counter that we increment one of the seeds on every
RandomState
creation, giving every correspondingHashMap
a different iteration order.
§Examples
use fasthash::{Seed, city};
city::hash128_with_seed(b"hello world", Seed::gen().into());
Implementations§
Trait Implementations§
impl Copy for Seed
Auto Trait Implementations§
impl Freeze for Seed
impl RefUnwindSafe for Seed
impl Send for Seed
impl Sync for Seed
impl Unpin for Seed
impl UnwindSafe for Seed
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