core: Forward ExactSizeIterator methods for important iterator adaptors
This commit is contained in:
parent
b1da18fe9b
commit
22739a148e
@ -368,7 +368,16 @@ fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() }
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I> ExactSizeIterator for Rev<I>
|
||||
where I: ExactSizeIterator + DoubleEndedIterator {}
|
||||
where I: ExactSizeIterator + DoubleEndedIterator
|
||||
{
|
||||
fn len(&self) -> usize {
|
||||
self.iter.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.iter.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "fused", issue = "35602")]
|
||||
impl<I> FusedIterator for Rev<I>
|
||||
@ -425,7 +434,15 @@ fn next_back(&mut self) -> Option<T> {
|
||||
#[stable(feature = "iter_cloned", since = "1.1.0")]
|
||||
impl<'a, I, T: 'a> ExactSizeIterator for Cloned<I>
|
||||
where I: ExactSizeIterator<Item=&'a T>, T: Clone
|
||||
{}
|
||||
{
|
||||
fn len(&self) -> usize {
|
||||
self.it.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.it.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "fused", issue = "35602")]
|
||||
impl<'a, I, T: 'a> FusedIterator for Cloned<I>
|
||||
@ -1007,7 +1024,16 @@ fn next_back(&mut self) -> Option<B> {
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F>
|
||||
where F: FnMut(I::Item) -> B {}
|
||||
where F: FnMut(I::Item) -> B
|
||||
{
|
||||
fn len(&self) -> usize {
|
||||
self.iter.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.iter.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "fused", issue = "35602")]
|
||||
impl<B, I: FusedIterator, F> FusedIterator for Map<I, F>
|
||||
@ -1236,7 +1262,15 @@ fn next_back(&mut self) -> Option<(usize, <I as Iterator>::Item)> {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {}
|
||||
impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {
|
||||
fn len(&self) -> usize {
|
||||
self.iter.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.iter.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
unsafe impl<I> TrustedRandomAccess for Enumerate<I>
|
||||
@ -1927,7 +1961,15 @@ fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
|
||||
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {}
|
||||
impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {
|
||||
fn len(&self) -> usize {
|
||||
self.iter.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.iter.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// An iterator that calls a function with a reference to each element before
|
||||
/// yielding it.
|
||||
@ -1994,7 +2036,16 @@ fn next_back(&mut self) -> Option<I::Item> {
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<I: ExactSizeIterator, F> ExactSizeIterator for Inspect<I, F>
|
||||
where F: FnMut(&I::Item) {}
|
||||
where F: FnMut(&I::Item)
|
||||
{
|
||||
fn len(&self) -> usize {
|
||||
self.iter.len()
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.iter.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "fused", issue = "35602")]
|
||||
impl<I: FusedIterator, F> FusedIterator for Inspect<I, F>
|
||||
|
Loading…
Reference in New Issue
Block a user