Skip to content

Commit

Permalink
Mention closures in docs for Clone and Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Mar 23, 2018
1 parent ee67e14 commit 00721de
Show file tree
Hide file tree
Showing 2 changed files with 10 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 @@ -63,6 +63,11 @@
/// This trait can be used with `#[derive]` if all fields are `Clone`. The `derive`d
/// implementation of [`clone`] calls [`clone`] on each field.
///
/// ## Closures
///
/// Closure types automatically implement `Clone` if they capture no value from the environment
/// or if all such captured values implement `Clone` themselves.
///
/// ## How can I implement `Clone`?
///
/// Types that are [`Copy`] should have a trivial implementation of `Clone`. More formally:
Expand Down
5 changes: 5 additions & 0 deletions src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ pub trait Unsize<T: ?Sized> {
/// are allowed to access `x` after the assignment. Under the hood, both a copy and a move
/// can result in bits being copied in memory, although this is sometimes optimized away.
///
/// ## Closures
///
/// Closure types automatically implement `Copy` if they capture no value from the environment
/// or if all such captured values implement `Copy` themselves.
///
/// ## How can I implement `Copy`?
///
/// There are two ways to implement `Copy` on your type. The simplest is to use `derive`:
Expand Down

0 comments on commit 00721de

Please sign in to comment.