mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Override nth for VecDeque Iter and IterMut
This commit is contained in:
@@ -2286,6 +2286,16 @@ fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
||||
final_res
|
||||
}
|
||||
|
||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
||||
if n >= count(self.tail, self.head, self.ring.len()) {
|
||||
self.tail = self.head;
|
||||
None
|
||||
} else {
|
||||
self.tail = wrap_index(self.tail.wrapping_add(n), self.ring.len());
|
||||
self.next()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn last(mut self) -> Option<&'a T> {
|
||||
self.next_back()
|
||||
@@ -2404,6 +2414,16 @@ fn fold<Acc, F>(self, mut accum: Acc, mut f: F) -> Acc
|
||||
back.iter_mut().fold(accum, &mut f)
|
||||
}
|
||||
|
||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
||||
if n >= count(self.tail, self.head, self.ring.len()) {
|
||||
self.tail = self.head;
|
||||
None
|
||||
} else {
|
||||
self.tail = wrap_index(self.tail.wrapping_add(n), self.ring.len());
|
||||
self.next()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn last(mut self) -> Option<&'a mut T> {
|
||||
self.next_back()
|
||||
|
||||
Reference in New Issue
Block a user