node: Better default for `RandomState`

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier 2022-08-29 11:16:08 +02:00
parent 5e0d4653c7
commit 5c41af060f
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -8,12 +8,18 @@ pub type HashMap<K, V> = std::collections::HashMap<K, V, RandomState>;
pub type HashSet<K> = std::collections::HashSet<K, RandomState>; pub type HashSet<K> = std::collections::HashSet<K, RandomState>;
/// Random hasher state. /// Random hasher state.
#[derive(Default, Clone)] #[derive(Clone)]
pub struct RandomState { pub struct RandomState {
key1: u64, key1: u64,
key2: u64, key2: u64,
} }
impl Default for RandomState {
fn default() -> Self {
Self::new(fastrand::Rng::new())
}
}
impl RandomState { impl RandomState {
fn new(rng: fastrand::Rng) -> Self { fn new(rng: fastrand::Rng) -> Self {
Self { Self {