Skip to content

Commit

Permalink
feat: support for IndexSet
Browse files Browse the repository at this point in the history
  • Loading branch information
huuff committed Oct 3, 2024
1 parent d499ff2 commit 627bc78
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion fake/src/impls/indexmap/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{Dummy, Fake, Faker};
use indexmap::IndexMap;
use indexmap::{IndexMap, IndexSet};
use rand::Rng;
use std::hash::{BuildHasher, Hash};

Expand All @@ -20,3 +20,18 @@ where
m
}
}

impl<T, S> Dummy<Faker> for IndexSet<T, S>
where
T: Dummy<Faker> + Hash + Eq,
S: BuildHasher + Default,
{
fn dummy_with_rng<R: Rng + ?Sized>(config: &Faker, rng: &mut R) -> Self {
let len = get_len(config, rng);
let mut m = IndexSet::with_capacity_and_hasher(len, S::default());
for _ in 0..len {
m.insert(config.fake_with_rng(rng));
}
m
}
}

0 comments on commit 627bc78

Please sign in to comment.