Skip to content

Commit

Permalink
Multipeek::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 db0311c commit fbe30e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/multipeek_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,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)
}
}

// Same size
Expand Down

0 comments on commit fbe30e7

Please sign in to comment.