mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 22:13:27 +00:00
implement RFC 1521
Adds documentation to Clone, specifying that Copy types should have a trivial Clone impl. Fixes #33416.
This commit is contained in:
parent
7a0ccc458f
commit
c5aa879490
@ -49,6 +49,11 @@ use marker::Sized;
|
||||
/// A common trait for cloning an object.
|
||||
///
|
||||
/// This trait can be used with `#[derive]`.
|
||||
///
|
||||
/// Types that are `Copy` should have a trivial implementation of `Clone`. More formally:
|
||||
/// if `T: Copy`, `x: T`, and `y: &T`, then `let x = y.clone();` is equivalent to `let x = *y;`.
|
||||
/// Manual implementations should be careful to uphold this invariant; however, unsafe code
|
||||
/// must not rely on it to ensure memory safety.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait Clone : Sized {
|
||||
/// Returns a copy of the value.
|
||||
|
Loading…
Reference in New Issue
Block a user