diff --git a/src/duplicates_impl.rs b/src/duplicates_impl.rs index a0db15432..317c9801c 100644 --- a/src/duplicates_impl.rs +++ b/src/duplicates_impl.rs @@ -81,6 +81,21 @@ mod private { iter.find_map(|v| meta.filter(v)) } + fn fold(self, init: B, mut f: G) -> B + where + Self: Sized, + G: FnMut(B, Self::Item) -> B, + { + let Self { iter, mut meta } = self; + iter.fold(init, |mut acc, v| { + if let Some(x) = meta.filter(v) { + acc = f(acc, x) + } + + acc + }) + } + #[inline] fn size_hint(&self) -> (usize, Option) { let (_, hi) = self.iter.size_hint();