Expand description
TheClone trait for types that cannot be ‘implicitly copied’.
In Rust, some simple types are “implicitly copyable” and when youassign them or pass them as arguments, the receiver will get a copy,leaving the original value in place. These types do not requireallocation to copy and do not have finalizers (i.e., they do notcontain owned boxes or implementDrop), so the compiler considersthem cheap and safe to copy. For other types copies must be madeexplicitly, by convention implementing theClone trait and callingtheclone method.
Basic usage example:
To easily implement the Clone trait, you can also use#[derive(Clone)]. Example:
Traits§
- Clone
- A common trait that allows explicit creation of a duplicate value.
- Clone
ToUninit Experimental - A generalization of
Clonetodynamically-sized types stored in arbitrary containers. - Trivial
Clone Experimental - Indicates that the
Cloneimplementation is identical to copying the value. - UseCloned
Experimental - Trait for objects whose
Cloneimpl is lightweight (e.g. reference-counted)
Derive Macros§
- Clone
- Derive macro generating an impl of the trait
Clone.