Forward more Iterator methods for iter::Rev

`position` could not be implemented because calling `rposition`
on the inner iterator would require more trait bounds.
This commit is contained in:
Simon Sapin 2017-07-05 20:23:55 +02:00 committed by Alex Crichton
parent b90e5107c0
commit 2007987099

View File

@ -359,11 +359,19 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
#[inline]
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
where P: FnMut(&Self::Item) -> bool
{
self.iter.rfind(predicate)
}
#[inline]
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool
{
self.iter.position(predicate)
}
}
#[stable(feature = "rust1", since = "1.0.0")]