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 pointers 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
of Clone for ()
of Clone for ~T where <T: Clone>
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 bool
of Clone for char
Clone
clone
fn clone(&self) -> Self
Clone
for ()
clone
fn clone(&self)
Clone
for ~T
where <T: Clone>
clone
fn clone(&self) -> ~T
Clone
for int
clone
fn clone(&self) -> int
Clone
for i8
clone
fn clone(&self) -> i8
Clone
for i16
clone
fn clone(&self) -> i16
Clone
for i32
clone
fn clone(&self) -> i32
Clone
for i64
clone
fn clone(&self) -> i64
Clone
for uint
clone
fn clone(&self) -> uint
Clone
for u8
clone
fn clone(&self) -> u8
Clone
for u16
clone
fn clone(&self) -> u16
Clone
for u32
clone
fn clone(&self) -> u32
Clone
for u64
clone
fn clone(&self) -> u64
Clone
for float
clone
fn clone(&self) -> float
Clone
for f32
clone
fn clone(&self) -> f32
Clone
for f64
clone
fn clone(&self) -> f64
Clone
for bool
clone
fn clone(&self) -> bool
Clone
for char
clone
fn clone(&self) -> char