Skip to content

Commit 00721de

Browse files
committed
Mention closures in docs for Clone and Copy
1 parent ee67e14 commit 00721de

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/libcore/clone.rs

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
/// This trait can be used with `#[derive]` if all fields are `Clone`. The `derive`d
6464
/// implementation of [`clone`] calls [`clone`] on each field.
6565
///
66+
/// ## Closures
67+
///
68+
/// Closure types automatically implement `Clone` if they capture no value from the environment
69+
/// or if all such captured values implement `Clone` themselves.
70+
///
6671
/// ## How can I implement `Clone`?
6772
///
6873
/// Types that are [`Copy`] should have a trivial implementation of `Clone`. More formally:

src/libcore/marker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ pub trait Unsize<T: ?Sized> {
166166
/// are allowed to access `x` after the assignment. Under the hood, both a copy and a move
167167
/// can result in bits being copied in memory, although this is sometimes optimized away.
168168
///
169+
/// ## Closures
170+
///
171+
/// Closure types automatically implement `Copy` if they capture no value from the environment
172+
/// or if all such captured values implement `Copy` themselves.
173+
///
169174
/// ## How can I implement `Copy`?
170175
///
171176
/// There are two ways to implement `Copy` on your type. The simplest is to use `derive`:

0 commit comments

Comments
 (0)