Skip to content

Commit f9f58c9

Browse files
committed
FIX: Use more efficient cloning in IntoIter::clone
Using .extend_from_slice() where possible.
1 parent cf283a0 commit f9f58c9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/arrayvec.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,9 @@ impl<T, const CAP: usize> Clone for IntoIter<T, CAP>
821821
where T: Clone,
822822
{
823823
fn clone(&self) -> IntoIter<T, CAP> {
824-
self.v[self.index..]
825-
.iter()
826-
.cloned()
827-
.collect::<ArrayVec<T, CAP>>()
828-
.into_iter()
824+
let mut v = ArrayVec::new();
825+
v.extend_from_slice(&self.v[self.index..]);
826+
v.into_iter()
829827
}
830828
}
831829

0 commit comments

Comments
 (0)