proptest_arbitrary/
tuples.rs1use super::*;
6
7macro_rules! impl_tuple {
8 ($($typ: ident),*) => {
9 impl<'a, $($typ : Arbitrary<'a>),*> Arbitrary<'a> for ($($typ,)*) {
10 valuetree!();
11 type Parameters = product_type![$($typ::Parameters,)*];
12 type Strategy = ($($typ::Strategy,)*);
13 fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
14 #[allow(non_snake_case)]
15 let product_unpack![$($typ),*] = args;
16 ($(any_with::<$typ>($typ)),*,)
17 }
18 }
19 };
20}
21
22arbitrary!((); ());
23impl_tuple!(T0);
24impl_tuple!(T0, T1);
25impl_tuple!(T0, T1, T2);
26impl_tuple!(T0, T1, T2, T3);
27impl_tuple!(T0, T1, T2, T3, T4);
28impl_tuple!(T0, T1, T2, T3, T4, T5);
29impl_tuple!(T0, T1, T2, T3, T4, T5, T6);
30impl_tuple!(T0, T1, T2, T3, T4, T5, T6, T7);
31impl_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8);
32impl_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9);
33
34#[cfg(test)]
35mod test {
36 no_panic_test!(
37 tuple_n10 => ((), bool, u8, u16, u32, u64, i8, i16, i32, i64)
38 );
39}