diff --git a/src/adaptors/mod.rs b/src/adaptors/mod.rs index 4d0f5e129..35d721a51 100644 --- a/src/adaptors/mod.rs +++ b/src/adaptors/mod.rs @@ -243,6 +243,26 @@ impl Iterator for PutBack size_hint::add_scalar(self.iter.size_hint(), self.top.is_some() as usize) } + fn count(self) -> usize { + self.iter.count() + (self.top.is_some() as usize) + } + + fn last(self) -> Option { + self.iter.last().or(self.top) + } + + fn nth(&mut self, n: usize) -> Option { + if let Some(top) = self.top.take() { + if n == 0 { + Some(top) + } else { + self.iter.nth(n - 1) + } + } else { + self.iter.nth(n) + } + } + fn all(&mut self, mut f: G) -> bool where G: FnMut(Self::Item) -> bool {