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.
This commit is contained in:
Marvin Löbel 2014-03-18 23:16:21 +01:00 committed by Alex Crichton
parent 848f7b734e
commit 113596655a

View File

@ -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));
}
}