diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index 6006d5f42..576d12917 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -715,7 +715,7 @@ macro_rules! impl_tuple_combination { impl Iterator for $C where I: Iterator + Clone, - I::Item: Clone + A: Clone, { type Item = (A, $(ignore_ident!($X, A)),*); @@ -745,6 +745,26 @@ macro_rules! impl_tuple_combination { let n = self.iter.count(); checked_binomial(n, K).unwrap() + self.c.count() } + + fn fold(self, mut init: B, mut f: F) -> B + where + F: FnMut(B, Self::Item) -> B, + { + let Self { c, item, mut iter } = self; + init = c + .map(|($($X),*,)| { + let z = item.clone().unwrap(); + (z, $($X),*) + }) + .fold(init, &mut f); + while let Some(z) = iter.next() { + let c: $P = iter.clone().into(); + init = c + .map(|($($X),*,)| (z.clone(), $($X),*)) + .fold(init, &mut f); + } + init + } } impl HasCombination for (A, $(ignore_ident!($X, A)),*)