| 1 |
use { |
| 2 |
crate::{Arbitrary, Result, Unstructured}, |
| 3 |
std::{ |
| 4 |
collections::hash_map::HashMap, |
| 5 |
hash::{BuildHasher, Hash}, |
| 6 |
}, |
| 7 |
}; |
| 8 |
|
| 9 |
impl<'a, K, V, S> Arbitrary<'a> for HashMap<K, V, S> |
| 10 |
where |
| 11 |
K: Arbitrary<'a> + Eq + Hash, |
| 12 |
V: Arbitrary<'a>, |
| 13 |
S: BuildHasher + Default, |
| 14 |
{ |
| 15 |
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { |
| 16 |
u.arbitrary_iter()?.collect() |
| 17 |
} |
| 18 |
|
| 19 |
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self> { |
| 20 |
u.arbitrary_take_rest_iter()?.collect() |
| 21 |
} |
| 22 |
|
| 23 |
#[inline] |
| 24 |
fn size_hint(_depth: usize) -> (usize, Option<usize>) { |
| 25 |
(0, None) |
| 26 |
} |
| 27 |
} |