Upgrade implementation of StepBy<RangeInclusive<_>>.
This commit is contained in:
parent
d299f03e28
commit
b6ea93e464
|
@ -787,17 +787,19 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn spec_next(&mut self) -> Option<Self::Item> {
|
fn spec_next(&mut self) -> Option<Self::Item> {
|
||||||
self.first_take = false;
|
self.first_take = false;
|
||||||
if !(self.iter.start <= self.iter.end) {
|
if self.iter.is_empty() {
|
||||||
|
self.iter.is_iterating = Some(false);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
// add 1 to self.step to get original step size back
|
// add 1 to self.step to get original step size back
|
||||||
// it was decremented for the general case on construction
|
// it was decremented for the general case on construction
|
||||||
if let Some(n) = self.iter.start.add_usize(self.step+1) {
|
if let Some(n) = self.iter.start.add_usize(self.step+1) {
|
||||||
|
self.iter.is_iterating = Some(n <= self.iter.end);
|
||||||
let next = mem::replace(&mut self.iter.start, n);
|
let next = mem::replace(&mut self.iter.start, n);
|
||||||
Some(next)
|
Some(next)
|
||||||
} else {
|
} else {
|
||||||
let last = self.iter.start.replace_one();
|
let last = self.iter.start.clone();
|
||||||
self.iter.end.replace_zero();
|
self.iter.is_iterating = Some(false);
|
||||||
Some(last)
|
Some(last)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue