From 00721de714785a8abf95a6403a66a19de6a58fc3 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 23 Mar 2018 11:37:11 +0100 Subject: [PATCH] Mention closures in docs for Clone and Copy --- src/libcore/clone.rs | 5 +++++ src/libcore/marker.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 826420a0c001c..d25f498b99efe 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -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: diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index f8a33961811c0..7d0174a178abf 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -166,6 +166,11 @@ pub trait Unsize { /// 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`: