Skip to content

Commit 298eb8b

Browse files
Philippe-Choletphimuemue
authored andcommitted
PeekNth::fold
1 parent 2357feb commit 298eb8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/peek_nth.rs

+8
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ where
152152
fn size_hint(&self) -> (usize, Option<usize>) {
153153
size_hint::add_scalar(self.iter.size_hint(), self.buf.len())
154154
}
155+
156+
fn fold<B, F>(self, mut init: B, mut f: F) -> B
157+
where
158+
F: FnMut(B, Self::Item) -> B,
159+
{
160+
init = self.buf.into_iter().fold(init, &mut f);
161+
self.iter.fold(init, f)
162+
}
155163
}
156164

157165
impl<I> ExactSizeIterator for PeekNth<I> where I: ExactSizeIterator {}

0 commit comments

Comments
 (0)