File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 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) {
196196///
197197/// The `UseCloned` trait does not provide a method; instead, it indicates that
198198/// `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.
199218#[ unstable( feature = "ergonomic_clones" , issue = "132290" ) ]
200219#[ cfg_attr( not( bootstrap) , lang = "use_cloned" ) ]
201220pub trait UseCloned : Clone {
Original file line number Diff line number Diff line change @@ -2121,8 +2121,8 @@ mod unsafe_keyword {}
21212121
21222122#[ doc( keyword = "use" ) ]
21232123//
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<..>`.
21262126///
21272127/// ## Importing items
21282128///
@@ -2205,6 +2205,11 @@ mod unsafe_keyword {}
22052205///
22062206/// For more details about precise capturing, see the [Reference][ref-impl-trait].
22072207///
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+ ///
22082213/// [`crate`]: keyword.crate.html
22092214/// [`self`]: keyword.self.html
22102215/// [`super`]: keyword.super.html
You can’t perform that action at this time.
0 commit comments