diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 5eea764b28a..644a1692943 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -1156,11 +1156,11 @@ fn spec_next(&mut self) -> Option { 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(&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(&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 { 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(&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(&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 }