diff options
| author | Daan Rijks <daanrijks@gmail.com> | 2015-08-30 17:32:43 +0200 |
|---|---|---|
| committer | Daan Rijks <daanrijks@gmail.com> | 2015-08-30 17:32:50 +0200 |
| commit | dacf2725ec6230e4b99486fd8f87cc9ab5ad995c (patch) | |
| tree | 54c73053bc8c669879327688ebd96730026cefb0 /src/libcore/str/mod.rs | |
| parent | 47ea0cfb6bd250c970e3a61d62bfa1b1c7bb27d4 (diff) | |
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.
Diffstat (limited to 'src/libcore/str/mod.rs')
| -rw-r--r-- | src/libcore/str/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 48118c18029..d9dffb76c64 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -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")] |
