Skip to content

Commit

Permalink
Rollup merge of rust-lang#33420 - durka:patch-20, r=alexcrichton
Browse files Browse the repository at this point in the history
implement RFC 1521

Adds documentation to Clone, specifying that Copy types should have a trivial Clone impl.

Fixes rust-lang#33416.

I tried to use "should" and "must" as defined [here](https://tools.ietf.org/html/rfc2119).

cc @ubsan
  • Loading branch information
Manishearth committed May 8, 2016
2 parents 30ce555 + c5aa879 commit f494058
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 f494058

Please sign in to comment.