Skip to content

Commit

Permalink
PeekNth::fold
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe-Cholet authored and phimuemue committed Dec 15, 2023
1 parent 2357feb commit 298eb8b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/peek_nth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ where
fn size_hint(&self) -> (usize, Option<usize>) {
size_hint::add_scalar(self.iter.size_hint(), self.buf.len())
}

fn fold<B, F>(self, mut init: B, mut f: F) -> B
where
F: FnMut(B, Self::Item) -> B,
{
init = self.buf.into_iter().fold(init, &mut f);
self.iter.fold(init, f)
}
}

impl<I> ExactSizeIterator for PeekNth<I> where I: ExactSizeIterator {}
Expand Down

0 comments on commit 298eb8b

Please sign in to comment.