Skip to content

Commit 29a6a9e

Browse files
committed
iter: Use underlying find/rfind for the same methods in Rev
1 parent fe15119 commit 29a6a9e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libcore/iter/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,24 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
358358
fn next(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next_back() }
359359
#[inline]
360360
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
361+
362+
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
363+
where P: FnMut(&Self::Item) -> bool
364+
{
365+
self.iter.rfind(predicate)
366+
}
361367
}
362368

363369
#[stable(feature = "rust1", since = "1.0.0")]
364370
impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator {
365371
#[inline]
366372
fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() }
373+
374+
fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
375+
where P: FnMut(&Self::Item) -> bool
376+
{
377+
self.iter.find(predicate)
378+
}
367379
}
368380

369381
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)