TrivialClone

Trait TrivialClone 

Source
pub unsafe trait TrivialClone: Clone { }
🔬This is a nightly-only experimental API. (trivial_clone)
Expand description

Indicates that the Clone implementation is identical to copying the value.

This is used for some optimizations in the standard library, which specializes on this trait to select faster implementations of functions such as clone_from_slice. It is automatically implemented when using #[derive(Clone, Copy)].

Note that this trait does not imply that the type is Copy, because e.g. core::ops::Range<i32> could soundly implement this trait.

§Safety

Clone::clone must be equivalent to copying the value, otherwise calling functions such as slice::clone_from_slice can have undefined behaviour.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§