Remove uneeded clones now that TrustedStep implies Copy
This is a follow up to 11fa1764ee
This commit is contained in:
parent
c7491b9733
commit
864eb7fa14
@ -1156,11 +1156,11 @@ fn spec_next(&mut self) -> Option<T> {
|
||||
let is_iterating = self.start < self.end;
|
||||
Some(if is_iterating {
|
||||
// SAFETY: just checked precondition
|
||||
let n = unsafe { Step::forward_unchecked(self.start.clone(), 1) };
|
||||
let n = unsafe { Step::forward_unchecked(self.start, 1) };
|
||||
mem::replace(&mut self.start, n)
|
||||
} else {
|
||||
self.exhausted = true;
|
||||
self.start.clone()
|
||||
self.start
|
||||
})
|
||||
}
|
||||
|
||||
@ -1179,7 +1179,7 @@ fn spec_try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
||||
|
||||
while self.start < self.end {
|
||||
// SAFETY: just checked precondition
|
||||
let n = unsafe { Step::forward_unchecked(self.start.clone(), 1) };
|
||||
let n = unsafe { Step::forward_unchecked(self.start, 1) };
|
||||
let n = mem::replace(&mut self.start, n);
|
||||
accum = f(accum, n)?;
|
||||
}
|
||||
@ -1187,7 +1187,7 @@ fn spec_try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
||||
self.exhausted = true;
|
||||
|
||||
if self.start == self.end {
|
||||
accum = f(accum, self.start.clone())?;
|
||||
accum = f(accum, self.start)?;
|
||||
}
|
||||
|
||||
try { accum }
|
||||
@ -1201,11 +1201,11 @@ fn spec_next_back(&mut self) -> Option<T> {
|
||||
let is_iterating = self.start < self.end;
|
||||
Some(if is_iterating {
|
||||
// SAFETY: just checked precondition
|
||||
let n = unsafe { Step::backward_unchecked(self.end.clone(), 1) };
|
||||
let n = unsafe { Step::backward_unchecked(self.end, 1) };
|
||||
mem::replace(&mut self.end, n)
|
||||
} else {
|
||||
self.exhausted = true;
|
||||
self.end.clone()
|
||||
self.end
|
||||
})
|
||||
}
|
||||
|
||||
@ -1224,7 +1224,7 @@ fn spec_try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
||||
|
||||
while self.start < self.end {
|
||||
// SAFETY: just checked precondition
|
||||
let n = unsafe { Step::backward_unchecked(self.end.clone(), 1) };
|
||||
let n = unsafe { Step::backward_unchecked(self.end, 1) };
|
||||
let n = mem::replace(&mut self.end, n);
|
||||
accum = f(accum, n)?;
|
||||
}
|
||||
@ -1232,7 +1232,7 @@ fn spec_try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
||||
self.exhausted = true;
|
||||
|
||||
if self.start == self.end {
|
||||
accum = f(accum, self.start.clone())?;
|
||||
accum = f(accum, self.start)?;
|
||||
}
|
||||
|
||||
try { accum }
|
||||
|
Loading…
Reference in New Issue
Block a user