Skip to content

Commit fee8019

Browse files
committed
Derive Clone for FxRandomState
1 parent eb049a8 commit fee8019

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/random_state.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub type FxHashSetRand<V> = HashSet<V, FxRandomState>;
1313
/// A particular instance `FxRandomState` will create the same instances of
1414
/// [`Hasher`], but the hashers created by two different `FxRandomState`
1515
/// instances are unlikely to produce the same result for the same values.
16+
#[derive(Clone)]
1617
pub struct FxRandomState {
1718
seed: usize,
1819
}
@@ -62,6 +63,15 @@ mod tests {
6263

6364
use crate::FxHashMapRand;
6465

66+
#[test]
67+
fn cloned_random_states_are_equal() {
68+
// The standard library's `RandomState` derives `Clone` without updating the seed.
69+
let a = FxHashMapRand::<&str, u32>::default();
70+
let b = a.clone();
71+
72+
assert_eq!(a.hasher().seed, b.hasher().seed);
73+
}
74+
6575
#[test]
6676
fn random_states_are_different() {
6777
let a = FxHashMapRand::<&str, u32>::default();

0 commit comments

Comments
 (0)