The Clone trait for types that cannot be "implicitly copied"
In Rust, some simple types are "implicitly copyable" and when you assign them or pass them as arguments, the receiver will get a copy, leaving the original value in place. These types do not require allocation to copy and do not have finalizers (i.e. they do not contain owned boxes or implement Drop
), so the compiler considers them cheap and safe to copy and automatically implements the Copy
trait for them. For other types copies must be made explicitly, by convention implementing the Clone
trait and calling the clone
method.
Clone
- A common trait for cloning an object.DeepClone
of Clone for ~T where <T: Clone>
of Clone for @T where <T>
of Clone for @mut T where <T>
of Clone for &'self T where <'self, T>
of Clone for &'self [T] where <'self, T>
of Clone for &'self str where <'self>
of Clone for int
of Clone for i8
of Clone for i16
of Clone for i32
of Clone for i64
of Clone for uint
of Clone for u8
of Clone for u16
of Clone for u32
of Clone for u64
of Clone for float
of Clone for f32
of Clone for f64
of Clone for ()
of Clone for bool
of Clone for char
of DeepClone for ~T where <T: DeepClone>
of DeepClone for @T where <T: Freeze + DeepClone>
of DeepClone for @mut T where <T: Freeze + DeepClone>
of DeepClone for int
of DeepClone for i8
of DeepClone for i16
of DeepClone for i32
of DeepClone for i64
of DeepClone for uint
of DeepClone for u8
of DeepClone for u16
of DeepClone for u32
of DeepClone for u64
of DeepClone for float
of DeepClone for f32
of DeepClone for f64
of DeepClone for ()
of DeepClone for bool
of DeepClone for char
Clone
A common trait for cloning an object.
clone
fn clone(&self) -> Self
Returns a copy of the value. The contents of owned pointers are copied to maintain uniqueness, while the contents of managed pointers are not copied.
DeepClone
A trait distinct from Clone
which represents "deep copies" of things like managed boxes which would otherwise not be copied.
deep_clone
fn deep_clone(&self) -> Self
Return a deep copy of the value. Unlike Clone
, the contents of shared pointer types are copied.
Clone
for ~T
where <T: Clone>
clone
fn clone(&self) -> ~T
Return a deep copy of the owned box.
Clone
for @T
where <T>
clone
fn clone(&self) -> @T
Return a shallow copy of the managed box.
Clone
for @mut T
where <T>
clone
fn clone(&self) -> @mut T
Return a shallow copy of the managed box.
Clone
for &'self T
where <'self, T>
clone
fn clone(&self) -> &'self T
Return a shallow copy of the borrowed pointer.
Clone
for &'self [T]
where <'self, T>
clone
fn clone(&self) -> &'self [T]
Return a shallow copy of the slice.
Clone
for &'self str
where <'self>
clone
fn clone(&self) -> &'self str
Return a shallow copy of the slice.
Clone
for int
clone
fn clone(&self) -> int
Return a deep copy of the value.
Clone
for i8
clone
fn clone(&self) -> i8
Return a deep copy of the value.
Clone
for i16
clone
fn clone(&self) -> i16
Return a deep copy of the value.
Clone
for i32
clone
fn clone(&self) -> i32
Return a deep copy of the value.
Clone
for i64
clone
fn clone(&self) -> i64
Return a deep copy of the value.
Clone
for uint
clone
fn clone(&self) -> uint
Return a deep copy of the value.
Clone
for u8
clone
fn clone(&self) -> u8
Return a deep copy of the value.
Clone
for u16
clone
fn clone(&self) -> u16
Return a deep copy of the value.
Clone
for u32
clone
fn clone(&self) -> u32
Return a deep copy of the value.
Clone
for u64
clone
fn clone(&self) -> u64
Return a deep copy of the value.
Clone
for float
clone
fn clone(&self) -> float
Return a deep copy of the value.
Clone
for f32
clone
fn clone(&self) -> f32
Return a deep copy of the value.
Clone
for f64
clone
fn clone(&self) -> f64
Return a deep copy of the value.
Clone
for ()
clone
fn clone(&self)
Return a deep copy of the value.
Clone
for bool
clone
fn clone(&self) -> bool
Return a deep copy of the value.
Clone
for char
clone
fn clone(&self) -> char
Return a deep copy of the value.
DeepClone
for ~T
where <T: DeepClone>
deep_clone
fn deep_clone(&self) -> ~T
Return a deep copy of the owned box.
DeepClone
for @T
where <T: Freeze + DeepClone>
deep_clone
fn deep_clone(&self) -> @T
Return a deep copy of the managed box. The Freeze
trait is required to prevent performing a deep clone of a potentially cyclical type.
DeepClone
for @mut T
where <T: Freeze + DeepClone>
deep_clone
fn deep_clone(&self) -> @mut T
Return a deep copy of the managed box. The Freeze
trait is required to prevent performing a deep clone of a potentially cyclical type.
DeepClone
for int
deep_clone
fn deep_clone(&self) -> int
Return a deep copy of the value.
DeepClone
for i8
deep_clone
fn deep_clone(&self) -> i8
Return a deep copy of the value.
DeepClone
for i16
deep_clone
fn deep_clone(&self) -> i16
Return a deep copy of the value.
DeepClone
for i32
deep_clone
fn deep_clone(&self) -> i32
Return a deep copy of the value.
DeepClone
for i64
deep_clone
fn deep_clone(&self) -> i64
Return a deep copy of the value.
DeepClone
for uint
deep_clone
fn deep_clone(&self) -> uint
Return a deep copy of the value.
DeepClone
for u8
deep_clone
fn deep_clone(&self) -> u8
Return a deep copy of the value.
DeepClone
for u16
deep_clone
fn deep_clone(&self) -> u16
Return a deep copy of the value.
DeepClone
for u32
deep_clone
fn deep_clone(&self) -> u32
Return a deep copy of the value.
DeepClone
for u64
deep_clone
fn deep_clone(&self) -> u64
Return a deep copy of the value.
DeepClone
for float
deep_clone
fn deep_clone(&self) -> float
Return a deep copy of the value.
DeepClone
for f32
deep_clone
fn deep_clone(&self) -> f32
Return a deep copy of the value.
DeepClone
for f64
deep_clone
fn deep_clone(&self) -> f64
Return a deep copy of the value.
DeepClone
for ()
deep_clone
fn deep_clone(&self)
Return a deep copy of the value.
DeepClone
for bool
deep_clone
fn deep_clone(&self) -> bool
Return a deep copy of the value.
DeepClone
for char
deep_clone
fn deep_clone(&self) -> char
Return a deep copy of the value.