Skip to content

Commit ba1a6f3

Browse files
committed
Add Rev delegate methods for the impl of Iterator.
1 parent fe6a54d commit ba1a6f3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/libcore/iter/mod.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -418,32 +418,45 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
418418
fn next(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next_back() }
419419
#[inline]
420420
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
421+
#[inline]
422+
fn count(self) -> usize { self.iter.count() }
423+
#[inline]
424+
fn last(mut self) -> Option<<I as Iterator>::Item> { self.iter.next() }
421425

422426
#[inline]
423427
fn nth(&mut self, n: usize) -> Option<<I as Iterator>::Item> { self.iter.nth_back(n) }
424428

429+
#[inline]
425430
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
426-
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
431+
Self: Sized, F: FnMut(B, <I as Iterator>::Item) -> R, R: Try<Ok=B>
427432
{
428433
self.iter.try_rfold(init, f)
429434
}
430435

436+
#[inline]
431437
fn fold<Acc, F>(self, init: Acc, f: F) -> Acc
432-
where F: FnMut(Acc, Self::Item) -> Acc,
438+
where F: FnMut(Acc, <I as Iterator>::Item) -> Acc,
433439
{
434440
self.iter.rfold(init, f)
435441
}
436442

437443
#[inline]
438-
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
439-
where P: FnMut(&Self::Item) -> bool
444+
fn find<P>(&mut self, predicate: P) -> Option<<I as Iterator>::Item>
445+
where P: FnMut(&<I as Iterator>::Item) -> bool
440446
{
441447
self.iter.rfind(predicate)
442448
}
443449

450+
#[inline]
451+
fn position<P>(&mut self, predicate: P) -> Option<usize> where
452+
P: FnMut(<I as Iterator>::Item) -> bool
453+
{
454+
self.iter.rposition(predicate)
455+
}
456+
444457
#[inline]
445458
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
446-
P: FnMut(Self::Item) -> bool
459+
P: FnMut(<I as Iterator>::Item) -> bool
447460
{
448461
self.iter.position(predicate)
449462
}

0 commit comments

Comments
 (0)