]> git.lizzy.rs Git - rust.git/blobdiff - src/libcollections/vec.rs
Rollup merge of #41249 - GuillaumeGomez:rustdoc-render, r=steveklabnik,frewsxcv
[rust.git] / src / libcollections / vec.rs
index 35ecf411db4e0b2a998b03a18be4fcd7404ec701..8824185d2809b1c5659fc2c7e98ebdcc898b6628 100644 (file)
@@ -1396,16 +1396,7 @@ fn clone(&self) -> Vec<T> {
     }
 
     fn clone_from(&mut self, other: &Vec<T>) {
-        // drop anything in self that will not be overwritten
-        self.truncate(other.len());
-        let len = self.len();
-
-        // reuse the contained values' allocations/resources.
-        self.clone_from_slice(&other[..len]);
-
-        // self.len <= other.len due to the truncate above, so the
-        // slice here is always in-bounds.
-        self.extend_from_slice(&other[len..]);
+        other.as_slice().clone_into(self);
     }
 }