about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Paseltiner <apaseltiner@gmail.com>2015-09-23 08:49:50 -0400
committerAndrew Paseltiner <apaseltiner@gmail.com>2015-09-23 10:32:58 -0400
commite9946f99b97fa1efda39b657448aae0238b66220 (patch)
tree1f4b6ae9fba7fd14976bf2de9b9234c647e71434
parent2a6f6f26f4d4a1e22ea5e2b4498d3245d80e8aff (diff)
downloadrust-e9946f99b97fa1efda39b657448aae0238b66220.tar.gz
rust-e9946f99b97fa1efda39b657448aae0238b66220.zip
Override `clone_from` for `{BinaryHeap, String}`
CC #28481
-rw-r--r--src/libcollections/binary_heap.rs12
-rw-r--r--src/libcollections/string.rs13
2 files changed, 23 insertions, 2 deletions
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs
index a3e32b59b71..b7afe968577 100644
--- a/src/libcollections/binary_heap.rs
+++ b/src/libcollections/binary_heap.rs
@@ -167,13 +167,23 @@ use vec::{self, Vec};
 /// item's ordering relative to any other item, as determined by the `Ord`
 /// trait, changes while it is in the heap. This is normally only possible
 /// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
-#[derive(Clone)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct BinaryHeap<T> {
     data: Vec<T>,
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+impl<T: Clone> Clone for BinaryHeap<T> {
+    fn clone(&self) -> Self {
+        BinaryHeap { data: self.data.clone() }
+    }
+
+    fn clone_from(&mut self, source: &Self) {
+        self.data.clone_from(&source.data);
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> Default for BinaryHeap<T> {
     #[inline]
     fn default() -> BinaryHeap<T> { BinaryHeap::new() }
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index bb65d7469ab..ba921fed68b 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -30,7 +30,7 @@ use vec::Vec;
 use boxed::Box;
 
 /// A growable string stored as a UTF-8 encoded buffer.
-#[derive(Clone, PartialOrd, Eq, Ord)]
+#[derive(PartialOrd, Eq, Ord)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct String {
     vec: Vec<u8>,
@@ -766,6 +766,17 @@ impl fmt::Display for FromUtf16Error {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+impl Clone for String {
+    fn clone(&self) -> Self {
+        String { vec: self.vec.clone() }
+    }
+
+    fn clone_from(&mut self, source: &Self) {
+        self.vec.clone_from(&source.vec);
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl FromIterator<char> for String {
     fn from_iter<I: IntoIterator<Item=char>>(iterable: I) -> String {
         let mut buf = String::new();