diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2014-03-18 23:16:21 +0100 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-03-18 16:29:57 -0700 |
| commit | 113596655aede43576c3107b62ba98ecaac5ebae (patch) | |
| tree | 040493187072e055f60159072ab2887657637272 /src/libstd | |
| parent | 848f7b734ec88964879f5a3051b940d48469ce2e (diff) | |
| download | rust-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')
| -rw-r--r-- | src/libstd/clone.rs | 3 |
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)); } } |
