about summary refs log tree commit diff
path: root/src/libstd/clone.rs
diff options
context:
space:
mode:
authorMarvin Löbel <loebel.marvin@gmail.com>2014-03-18 23:16:21 +0100
committerAlex Crichton <alex@alexcrichton.com>2014-03-18 16:29:57 -0700
commit113596655aede43576c3107b62ba98ecaac5ebae (patch)
tree040493187072e055f60159072ab2887657637272 /src/libstd/clone.rs
parent848f7b734ec88964879f5a3051b940d48469ce2e (diff)
downloadrust-113596655aede43576c3107b62ba98ecaac5ebae.tar.gz
rust-113596655aede43576c3107b62ba98ecaac5ebae.zip
Made the `clone_from` implementation for `~T` reuse the `T` itself if
possible by also calling `clone_from` on it.

In general, `Clone` implementors that overwrite `clone_from`
should try to to use it recursivly for substructures.
Diffstat (limited to 'src/libstd/clone.rs')
-rw-r--r--src/libstd/clone.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs
index ce5f056622f..cf5a9c6711c 100644
--- a/src/libstd/clone.rs
+++ b/src/libstd/clone.rs
@@ -45,8 +45,9 @@ impl<T: Clone> Clone for ~T {
     fn clone(&self) -> ~T { ~(**self).clone() }
 
     /// Perform copy-assignment from `source` by reusing the existing allocation.
+    #[inline]
     fn clone_from(&mut self, source: &~T) {
-        **self = (**source).clone()
+        (**self).clone_from(&(**source));
     }
 }