From 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 14:41:41 +0200 Subject: Merging upstream version 1.70.0+dfsg2. Signed-off-by: Daniel Baumann --- vendor/im-rc/src/quickcheck.rs | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 vendor/im-rc/src/quickcheck.rs (limited to 'vendor/im-rc/src/quickcheck.rs') diff --git a/vendor/im-rc/src/quickcheck.rs b/vendor/im-rc/src/quickcheck.rs new file mode 100644 index 000000000..3faade751 --- /dev/null +++ b/vendor/im-rc/src/quickcheck.rs @@ -0,0 +1,43 @@ +use crate::{HashMap, HashSet, OrdMap, OrdSet, Vector}; +use ::quickcheck::{Arbitrary, Gen}; +use std::hash::{BuildHasher, Hash}; +use std::iter::FromIterator; + +impl Arbitrary for Vector { + fn arbitrary(g: &mut Gen) -> Self { + Vector::from_iter(Vec::::arbitrary(g)) + } +} + +impl Arbitrary for OrdMap { + fn arbitrary(g: &mut Gen) -> Self { + OrdMap::from_iter(Vec::<(K, V)>::arbitrary(g)) + } +} + +impl Arbitrary for OrdSet { + fn arbitrary(g: &mut Gen) -> Self { + OrdSet::from_iter(Vec::::arbitrary(g)) + } +} + +impl Arbitrary for HashSet +where + A: Hash + Eq + Arbitrary + Sync, + S: BuildHasher + Default + Send + Sync + 'static, +{ + fn arbitrary(g: &mut Gen) -> Self { + HashSet::from_iter(Vec::::arbitrary(g)) + } +} + +impl Arbitrary for HashMap +where + K: Hash + Eq + Arbitrary + Sync, + V: Arbitrary + Sync, + S: BuildHasher + Default + Send + Sync + 'static, +{ + fn arbitrary(g: &mut Gen) -> Self { + HashMap::from(Vec::<(K, V)>::arbitrary(g)) + } +} -- cgit v1.2.3