We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0872a59 commit c1b7250Copy full SHA for c1b7250
src/lib.rs
@@ -893,22 +893,16 @@ impl<A: Array> Clone for ArrayVec<A>
893
fn clone_from(&mut self, rhs: &Self) {
894
// recursive case for the common prefix
895
let prefix = cmp::min(self.len(), rhs.len());
896
- {
897
- let a = &mut self[..prefix];
898
- let b = &rhs[..prefix];
899
- for i in 0..prefix {
900
- a[i].clone_from(&b[i]);
901
- }
902
+ self[..prefix].clone_from_slice(&rhs[..prefix]);
+
903
if prefix < self.len() {
904
// rhs was shorter
905
for _ in 0..self.len() - prefix {
906
self.pop();
907
}
908
} else {
909
- for elt in &rhs[self.len()..] {
910
- self.push(elt.clone());
911
+ let rhs_elems = rhs[self.len()..].iter().cloned();
+ self.extend(rhs_elems);
912
913
914
0 commit comments