diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-12-02 21:13:57 +0100 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-12-02 21:20:41 +0100 |
| commit | bc3618e5c007e69e6b21b2aa4d2aad110da6655e (patch) | |
| tree | 9582ce154baf0846883139b84acd0a2ec03de30c /src/libcore | |
| parent | 73e98a0210f0afdec28b4f5bc0f7327d6a5a8555 (diff) | |
| download | rust-bc3618e5c007e69e6b21b2aa4d2aad110da6655e.tar.gz rust-bc3618e5c007e69e6b21b2aa4d2aad110da6655e.zip | |
core: Remove Self: Sized from Iterator::nth
It is an unnecessary restriction; nth neither needs self to be sized nor needs to be exempted from the trait object. It increases the utility of the nth method, because type specific implementations are available through `&mut I` or through an iterator trait object. It is a backwards compatible change due to the special cases of the `where Self: Sized` bound; it was already optional to include this bound in `Iterator` implementations.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter/iterator.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index f6b74a91c19..48808b601c1 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -247,7 +247,7 @@ pub trait Iterator { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - fn nth(&mut self, mut n: usize) -> Option<Self::Item> where Self: Sized { + fn nth(&mut self, mut n: usize) -> Option<Self::Item> { for x in self { if n == 0 { return Some(x) } n -= 1; @@ -2179,4 +2179,7 @@ impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I { type Item = I::Item; fn next(&mut self) -> Option<I::Item> { (**self).next() } fn size_hint(&self) -> (usize, Option<usize>) { (**self).size_hint() } + fn nth(&mut self, n: usize) -> Option<Self::Item> { + (**self).nth(n) + } } |
