Skip to content

Commit

Permalink
Merge pull request #196 from huuff/indexmap
Browse files Browse the repository at this point in the history
feat: support for IndexSet
  • Loading branch information
cksac authored Oct 4, 2024
2 parents a11ac07 + 627bc78 commit 5c083eb
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 5c083eb

Please sign in to comment.