Skip to content

Commit

Permalink
Use zipped iterators in clone_from for LinkedList
Browse files Browse the repository at this point in the history
  • Loading branch information
crgl committed Oct 2, 2019
1 parent 7b480cd commit 5055d4b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,8 +1203,8 @@ impl<T: Clone> Clone for LinkedList<T> {
if self.len() > other.len() {
self.split_off(other.len());
}
for elem in self.iter_mut() {
elem.clone_from(iter_other.next().unwrap());
for (elem, elem_other) in self.iter_mut().zip(&mut iter_other) {
elem.clone_from(elem_other);
}
if !iter_other.is_empty() {
self.extend(iter_other.cloned());
Expand Down

0 comments on commit 5055d4b

Please sign in to comment.