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.

Trait Clone

A common trait for cloning an object.

Method 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.

Trait DeepClone

A trait distinct from Clone which represents "deep copies" of things like managed boxes which would otherwise not be copied.

Method deep_clone

fn deep_clone(&self) -> Self

Return a deep copy of the value. Unlike Clone, the contents of shared pointer types are copied.

Implementation of Clone for ~T where <T: Clone>

Method clone

fn clone(&self) -> ~T

Return a deep copy of the owned box.

Implementation of Clone for @T where <T>

Method clone

fn clone(&self) -> @T

Return a shallow copy of the managed box.

Implementation of Clone for @mut T where <T>

Method clone

fn clone(&self) -> @mut T

Return a shallow copy of the managed box.

Implementation of Clone for &'self T where <'self, T>

Method clone

fn clone(&self) -> &'self T

Return a shallow copy of the borrowed pointer.

Implementation of Clone for &'self [T] where <'self, T>

Method clone

fn clone(&self) -> &'self [T]

Return a shallow copy of the slice.

Implementation of Clone for &'self str where <'self>

Method clone

fn clone(&self) -> &'self str

Return a shallow copy of the slice.

Implementation of Clone for int

Method clone

fn clone(&self) -> int

Return a deep copy of the value.

Implementation of Clone for i8

Method clone

fn clone(&self) -> i8

Return a deep copy of the value.

Implementation of Clone for i16

Method clone

fn clone(&self) -> i16

Return a deep copy of the value.

Implementation of Clone for i32

Method clone

fn clone(&self) -> i32

Return a deep copy of the value.

Implementation of Clone for i64

Method clone

fn clone(&self) -> i64

Return a deep copy of the value.

Implementation of Clone for uint

Method clone

fn clone(&self) -> uint

Return a deep copy of the value.

Implementation of Clone for u8

Method clone

fn clone(&self) -> u8

Return a deep copy of the value.

Implementation of Clone for u16

Method clone

fn clone(&self) -> u16

Return a deep copy of the value.

Implementation of Clone for u32

Method clone

fn clone(&self) -> u32

Return a deep copy of the value.

Implementation of Clone for u64

Method clone

fn clone(&self) -> u64

Return a deep copy of the value.

Implementation of Clone for float

Method clone

fn clone(&self) -> float

Return a deep copy of the value.

Implementation of Clone for f32

Method clone

fn clone(&self) -> f32

Return a deep copy of the value.

Implementation of Clone for f64

Method clone

fn clone(&self) -> f64

Return a deep copy of the value.

Implementation of Clone for ()

Method clone

fn clone(&self)

Return a deep copy of the value.

Implementation of Clone for bool

Method clone

fn clone(&self) -> bool

Return a deep copy of the value.

Implementation of Clone for char

Method clone

fn clone(&self) -> char

Return a deep copy of the value.

Implementation of DeepClone for ~T where <T: DeepClone>

Method deep_clone

fn deep_clone(&self) -> ~T

Return a deep copy of the owned box.

Implementation of DeepClone for @T where <T: Freeze + DeepClone>

Method 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.

Implementation of DeepClone for @mut T where <T: Freeze + DeepClone>

Method 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.

Implementation of DeepClone for int

Method deep_clone

fn deep_clone(&self) -> int

Return a deep copy of the value.

Implementation of DeepClone for i8

Method deep_clone

fn deep_clone(&self) -> i8

Return a deep copy of the value.

Implementation of DeepClone for i16

Method deep_clone

fn deep_clone(&self) -> i16

Return a deep copy of the value.

Implementation of DeepClone for i32

Method deep_clone

fn deep_clone(&self) -> i32

Return a deep copy of the value.

Implementation of DeepClone for i64

Method deep_clone

fn deep_clone(&self) -> i64

Return a deep copy of the value.

Implementation of DeepClone for uint

Method deep_clone

fn deep_clone(&self) -> uint

Return a deep copy of the value.

Implementation of DeepClone for u8

Method deep_clone

fn deep_clone(&self) -> u8

Return a deep copy of the value.

Implementation of DeepClone for u16

Method deep_clone

fn deep_clone(&self) -> u16

Return a deep copy of the value.

Implementation of DeepClone for u32

Method deep_clone

fn deep_clone(&self) -> u32

Return a deep copy of the value.

Implementation of DeepClone for u64

Method deep_clone

fn deep_clone(&self) -> u64

Return a deep copy of the value.

Implementation of DeepClone for float

Method deep_clone

fn deep_clone(&self) -> float

Return a deep copy of the value.

Implementation of DeepClone for f32

Method deep_clone

fn deep_clone(&self) -> f32

Return a deep copy of the value.

Implementation of DeepClone for f64

Method deep_clone

fn deep_clone(&self) -> f64

Return a deep copy of the value.

Implementation of DeepClone for ()

Method deep_clone

fn deep_clone(&self)

Return a deep copy of the value.

Implementation of DeepClone for bool

Method deep_clone

fn deep_clone(&self) -> bool

Return a deep copy of the value.

Implementation of DeepClone for char

Method deep_clone

fn deep_clone(&self) -> char

Return a deep copy of the value.