File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,25 @@ pub macro Clone($item:item) {
196
196
///
197
197
/// The `UseCloned` trait does not provide a method; instead, it indicates that
198
198
/// `Clone::clone` is lightweight, and allows the use of the `.use` syntax.
199
+ ///
200
+ /// ## .use postfix syntax
201
+ ///
202
+ /// Values can be `.use`d by adding `.use` postfix to the value you want to use.
203
+ ///
204
+ /// ```ignore (this won't work until we land use)
205
+ /// fn foo(f: Foo) {
206
+ /// // if `Foo` implements `Copy` f would be copied into x.
207
+ /// // if `Foo` implements `UseCloned` f would be cloned into x.
208
+ /// // otherwise f would be moved into x.
209
+ /// let x = f.use;
210
+ /// // ...
211
+ /// }
212
+ /// ```
213
+ ///
214
+ /// ## use closures
215
+ ///
216
+ /// Use closures allow captured values to be automatically used.
217
+ /// This is similar to have a closure that you would call `.use` over each captured value.
199
218
#[ unstable( feature = "ergonomic_clones" , issue = "132290" ) ]
200
219
#[ cfg_attr( not( bootstrap) , lang = "use_cloned" ) ]
201
220
pub trait UseCloned : Clone {
Original file line number Diff line number Diff line change @@ -2121,8 +2121,8 @@ mod unsafe_keyword {}
2121
2121
2122
2122
#[ doc( keyword = "use" ) ]
2123
2123
//
2124
- /// Import or rename items from other crates or modules, or specify precise capturing
2125
- /// with `use<..>`.
2124
+ /// Import or rename items from other crates or modules, use values under ergonomic clones
2125
+ /// semantic, or specify precise capturing with `use<..>`.
2126
2126
///
2127
2127
/// ## Importing items
2128
2128
///
@@ -2205,6 +2205,11 @@ mod unsafe_keyword {}
2205
2205
///
2206
2206
/// For more details about precise capturing, see the [Reference][ref-impl-trait].
2207
2207
///
2208
+ /// ## Ergonomic clones
2209
+ ///
2210
+ /// Use a values, copying its content if the value implements `Copy`, cloning the contents if the
2211
+ /// value implements `UseCloned` or moving it otherwise.
2212
+ ///
2208
2213
/// [`crate`]: keyword.crate.html
2209
2214
/// [`self`]: keyword.self.html
2210
2215
/// [`super`]: keyword.super.html
You can’t perform that action at this time.
0 commit comments