Sha256: 66e9361bec0d62d2f4214ddab266fee2258cbf52c1243f8882612861b2bd98f1
Contents?: true
Size: 1.37 KB
Versions: 3
Compression:
Stored size: 1.37 KB
Contents
use crate::{size_hint, Arbitrary, MaxRecursionReached, Result, Unstructured}; macro_rules! arbitrary_tuple { () => {}; ($last: ident $($xs: ident)*) => { arbitrary_tuple!($($xs)*); impl<'a, $($xs,)* $last> Arbitrary<'a> for ($($xs,)* $last,) where $($xs: Arbitrary<'a>,)* $last: Arbitrary<'a>, { fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { Ok(($($xs::arbitrary(u)?,)* Arbitrary::arbitrary(u)?,)) } #[allow(unused_mut, non_snake_case)] fn arbitrary_take_rest(mut u: Unstructured<'a>) -> Result<Self> { $(let $xs = $xs::arbitrary(&mut u)?;)* let $last = $last::arbitrary_take_rest(u)?; Ok(($($xs,)* $last,)) } #[inline] fn size_hint(depth: usize) -> (usize, Option<usize>) { Self::try_size_hint(depth).unwrap_or_default() } #[inline] fn try_size_hint(depth: usize) -> Result<(usize, Option<usize>), MaxRecursionReached> { Ok(size_hint::and_all(&[ <$last as Arbitrary>::try_size_hint(depth)?, $( <$xs as Arbitrary>::try_size_hint(depth)?),* ])) } } }; } arbitrary_tuple!(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
Version data entries
3 entries across 3 versions & 1 rubygems