use super::{biguint_from_vec, BigUint}; use crate::big_digit::BigDigit; #[cfg(feature = "quickcheck")] use crate::std_alloc::Box; use crate::std_alloc::Vec; #[cfg(feature = "quickcheck")] impl quickcheck::Arbitrary for BigUint { fn arbitrary(g: &mut quickcheck::Gen) -> Self { // Use arbitrary from Vec biguint_from_vec(Vec::::arbitrary(g)) } fn shrink(&self) -> Box> { // Use shrinker from Vec Box::new(self.data.shrink().map(biguint_from_vec)) } } #[cfg(feature = "arbitrary")] impl arbitrary::Arbitrary<'_> for BigUint { fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result { Ok(biguint_from_vec(Vec::::arbitrary(u)?)) } fn arbitrary_take_rest(u: arbitrary::Unstructured<'_>) -> arbitrary::Result { Ok(biguint_from_vec(Vec::::arbitrary_take_rest(u)?)) } fn size_hint(depth: usize) -> (usize, Option) { Vec::::size_hint(depth) } }