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