diff --git a/fake/src/impls/indexmap/mod.rs b/fake/src/impls/indexmap/mod.rs index 849ef9c..ec68aa0 100644 --- a/fake/src/impls/indexmap/mod.rs +++ b/fake/src/impls/indexmap/mod.rs @@ -1,5 +1,5 @@ use crate::{Dummy, Fake, Faker}; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use rand::Rng; use std::hash::{BuildHasher, Hash}; @@ -20,3 +20,18 @@ where m } } + +impl Dummy for IndexSet +where + T: Dummy + Hash + Eq, + S: BuildHasher + Default, +{ + fn dummy_with_rng(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 + } +}