diff --git a/src/random_state.rs b/src/random_state.rs index b70ba4d..7f94073 100644 --- a/src/random_state.rs +++ b/src/random_state.rs @@ -13,6 +13,7 @@ pub type FxHashSetRand = HashSet; /// A particular instance `FxRandomState` will create the same instances of /// [`Hasher`], but the hashers created by two different `FxRandomState` /// instances are unlikely to produce the same result for the same values. +#[derive(Clone)] pub struct FxRandomState { seed: usize, } @@ -62,6 +63,15 @@ mod tests { use crate::FxHashMapRand; + #[test] + fn cloned_random_states_are_equal() { + // The standard library's `RandomState` does this, so we should too. + let a = FxHashMapRand::<&str, u32>::default(); + let b = a.clone(); + + assert_eq!(a.hasher().seed, b.hasher().seed); + } + #[test] fn random_states_are_different() { let a = FxHashMapRand::<&str, u32>::default();