Skip to content

Commit b4a306c

Browse files
committed
Avoid calling clone in DoubleEndedIterator implementation of Copied
1 parent 431968d commit b4a306c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libcore/iter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@ impl<'a, I, T: 'a> DoubleEndedIterator for Copied<I>
553553
fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R where
554554
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
555555
{
556-
self.it.try_rfold(init, move |acc, elt| f(acc, elt.clone()))
556+
self.it.try_rfold(init, move |acc, &elt| f(acc, elt))
557557
}
558558

559559
fn rfold<Acc, F>(self, init: Acc, mut f: F) -> Acc
560560
where F: FnMut(Acc, Self::Item) -> Acc,
561561
{
562-
self.it.rfold(init, move |acc, elt| f(acc, elt.clone()))
562+
self.it.rfold(init, move |acc, &elt| f(acc, elt))
563563
}
564564
}
565565

0 commit comments

Comments
 (0)