Skip to content

Commit

Permalink
Derive Clone for FxSeededState
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Sep 25, 2024
1 parent fee8019 commit 23fcdff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/random_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ mod tests {

#[test]
fn cloned_random_states_are_equal() {
// The standard library's `RandomState` derives `Clone` without updating the seed.
let a = FxHashMapRand::<&str, u32>::default();
let b = a.clone();

Expand Down
13 changes: 13 additions & 0 deletions src/seeded_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub type FxHashSetSeed<V> = std::collections::HashSet<V, FxSeededState>;
/// map.insert(15, 610);
/// assert_eq!(map[&15], 610);
/// ```
#[derive(Clone)]
pub struct FxSeededState {
seed: usize,
}
Expand All @@ -43,6 +44,18 @@ mod tests {

use crate::FxSeededState;

#[test]
fn cloned_seeded_states_are_equal() {
let seed = 2;
let a = FxSeededState::with_seed(seed);
let b = a.clone();

assert_eq!(a.seed, b.seed);
assert_eq!(a.seed, seed);

assert_eq!(a.build_hasher().hash, b.build_hasher().hash);
}

#[test]
fn same_seed_produces_same_hasher() {
let seed = 1;
Expand Down

0 comments on commit 23fcdff

Please sign in to comment.