diff --git a/src/put_back_n_impl.rs b/src/put_back_n_impl.rs index 9b23fa7d5..40b55e5f6 100644 --- a/src/put_back_n_impl.rs +++ b/src/put_back_n_impl.rs @@ -59,4 +59,12 @@ impl Iterator for PutBackN { fn size_hint(&self) -> (usize, Option) { size_hint::add_scalar(self.iter.size_hint(), self.top.len()) } + + fn fold(self, mut init: B, mut f: F) -> B + where + F: FnMut(B, Self::Item) -> B, + { + init = self.top.into_iter().rfold(init, &mut f); + self.iter.fold(init, f) + } }