Skip to content

Commit

Permalink
implement RFC 1521
Browse files Browse the repository at this point in the history
Adds documentation to Clone, specifying that Copy types should have a trivial Clone impl.

Fixes rust-lang#33416.
  • Loading branch information
durka committed May 5, 2016
1 parent 7a0ccc4 commit c5aa879
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c5aa879

Please sign in to comment.