From 864eb7fa14c25de655e03d692c5da798d3d98413 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Fri, 12 Apr 2024 17:47:30 +0200 Subject: [PATCH] Remove uneeded clones now that TrustedStep implies Copy This is a follow up to 11fa1764ee4819aa674ca861c5e9a8fafd7a59e6 --- library/core/src/iter/range.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 5eea764b28adc..644a169294396 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -1156,11 +1156,11 @@ impl RangeInclusiveIteratorImpl for ops::RangeInclusive { 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 @@ impl RangeInclusiveIteratorImpl for ops::RangeInclusive { 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 @@ impl RangeInclusiveIteratorImpl for ops::RangeInclusive { 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 @@ impl RangeInclusiveIteratorImpl for ops::RangeInclusive { 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 @@ impl RangeInclusiveIteratorImpl for ops::RangeInclusive { 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 @@ impl RangeInclusiveIteratorImpl for ops::RangeInclusive { self.exhausted = true; if self.start == self.end { - accum = f(accum, self.start.clone())?; + accum = f(accum, self.start)?; } try { accum }