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:
parent
848f7b734e
commit
113596655a
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user