Trait TrivialClone

unsafe trait TrivialClone: ~const Clone

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.