Skip to content

Commit 2357feb

Browse files
Philippe-Choletphimuemue
authored andcommitted
PutBackN::fold
1 parent fbe30e7 commit 2357feb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/put_back_n_impl.rs

+8
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,12 @@ impl<I: Iterator> Iterator for PutBackN<I> {
5959
fn size_hint(&self) -> (usize, Option<usize>) {
6060
size_hint::add_scalar(self.iter.size_hint(), self.top.len())
6161
}
62+
63+
fn fold<B, F>(self, mut init: B, mut f: F) -> B
64+
where
65+
F: FnMut(B, Self::Item) -> B,
66+
{
67+
init = self.top.into_iter().rfold(init, &mut f);
68+
self.iter.fold(init, f)
69+
}
6270
}

0 commit comments

Comments
 (0)