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 @@ -465,6 +465,25 @@ impl<T: ?Sized> Copy for &T {}
465465///
466466/// The `UseCloned` trait does not provide a method; instead, it indicates that
467467/// `Clone::clone` is lightweight, and allows the use of the `.use` syntax.
468+ ///
469+ /// ## .use postfix syntax
470+ ///
471+ /// Values can be `.use`d by adding `.use` postfix to the value you want to use.
472+ ///
473+ /// ```
474+ /// fn foo(f: Foo) {
475+ /// // if `Foo` implements `Copy` f would be copied into x.
476+ /// // if `Foo` implements `UseCloned` f would be cloned into x.
477+ /// // otherwise f would be moved into x.
478+ /// let x = f.use;
479+ /// // ...
480+ /// }
481+ /// ```
482+ ///
483+ /// ## use closures
484+ ///
485+ /// Use closures allow captured values to be automatically used.
486+ /// This is similar to have a closure that you would call `.use` over each captured value.
468487#[ unstable( feature = "ergonomic_clones" , issue = "132290" ) ]
469488#[ cfg_attr( not( bootstrap) , lang = "use_cloned" ) ]
470489#[ marker]
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///
@@ -2177,6 +2177,11 @@ mod unsafe_keyword {}
21772177/// The differences about paths and the `use` keyword between the 2015 and 2018 editions
21782178/// can also be found in the [Reference][ref-use-decls].
21792179///
2180+ /// ## Ergonomic clones
2181+ ///
2182+ /// Use a values, copying its content if the value implements `Copy`, cloning the contents if the
2183+ /// value implements `UseCloned` or moving it otherwise.
2184+ ///
21802185/// ## Precise capturing
21812186///
21822187/// The `use<..>` syntax is used within certain `impl Trait` bounds to control which generic
You can’t perform that action at this time.
0 commit comments