Add overrides to iterator methods for str::Bytes

Specifically, `count`, `last`, and `nth` are implemented to use the
methods of the underlying slice iterator.

Partially closes #24214.
This commit is contained in:
Daan Rijks
2015-08-30 17:32:43 +02:00
parent 47ea0cfb6b
commit dacf2725ec
2 changed files with 46 additions and 0 deletions

View File

@@ -387,6 +387,21 @@ impl<'a> Iterator for Bytes<'a> {
fn size_hint(&self) -> (usize, Option<usize>) {
self.0.size_hint()
}
#[inline]
fn count(self) -> usize {
self.0.count()
}
#[inline]
fn last(self) -> Option<Self::Item> {
self.0.last()
}
#[inline]
fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.0.nth(n)
}
}
#[stable(feature = "rust1", since = "1.0.0")]