iter: Use underlying find/rfind for the same methods in Rev

This commit is contained in:
Ulrik Sverdrup 2017-04-03 02:03:12 +02:00
parent fe151194e9
commit 29a6a9e8d2

View File

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