itertools/
cons_tuples_impl.rs1use crate::adaptors::map::{MapSpecialCase, MapSpecialCaseFn};
2
3macro_rules! impl_cons_iter(
4    ($_A:ident, $_B:ident, ) => (); ($A:ident, $($B:ident,)*) => (
7        impl_cons_iter!($($B,)*);
8        #[allow(non_snake_case)]
9        impl<$($B),*, X> MapSpecialCaseFn<(($($B,)*), X)> for ConsTuplesFn {
10            type Out = ($($B,)* X, );
11            fn call(&mut self, (($($B,)*), X): (($($B,)*), X)) -> Self::Out {
12                ($($B,)* X, )
13            }
14        }
15    );
16);
17
18impl_cons_iter!(A, B, C, D, E, F, G, H, I, J, K, L,);
19
20#[derive(Debug, Clone)]
21pub struct ConsTuplesFn;
22
23pub type ConsTuples<I> = MapSpecialCase<I, ConsTuplesFn>;
28
29pub fn cons_tuples<I>(iterable: I) -> ConsTuples<I::IntoIter>
32where
33    I: IntoIterator,
34{
35    ConsTuples {
36        iter: iterable.into_iter(),
37        f: ConsTuplesFn,
38    }
39}