mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-12 08:36:03 +00:00
implement nth_back for Fuse
This commit is contained in:
parent
cc2689a253
commit
fae2a68ba2
@ -1789,6 +1789,17 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
default fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
|
||||
if self.done {
|
||||
None
|
||||
} else {
|
||||
let nth = self.iter.nth_back(n);
|
||||
self.done = nth.is_none();
|
||||
nth
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
default fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where
|
||||
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
|
||||
@ -1877,6 +1888,11 @@ impl<I> DoubleEndedIterator for Fuse<I>
|
||||
self.iter.next_back()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
|
||||
self.iter.nth_back(n)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn try_rfold<Acc, Fold, R>(&mut self, init: Acc, fold: Fold) -> R where
|
||||
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
|
||||
|
Loading…
Reference in New Issue
Block a user