Skip to content

Commit

Permalink
Forward more Iterator methods for iter::Rev
Browse files Browse the repository at this point in the history
`position` could not be implemented because calling `rposition`
on the inner iterator would require more trait bounds.
  • Loading branch information
SimonSapin authored and alexcrichton committed Jul 13, 2017
1 parent b90e510 commit 2007987
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit 2007987

Please sign in to comment.