File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -945,18 +945,30 @@ mod mod_keyword {}
945945/// `move` converts any variables captured by reference or mutable reference
946946/// to owned by value variables.
947947///
948- /// Note: `move` closures may still implement [`Fn`] or [`FnMut`], even though
949- /// they capture variables by `move`. This is because the traits implemented by
950- /// a closure type are determined by *what* the closure does with captured
951- /// values, not *how* it captures them.
952- ///
953948/// ```rust
954949/// let capture = "hello";
955950/// let closure = move || {
956951/// println!("rust says {}", capture);
957952/// };
958953/// ```
959954///
955+ /// Note: `move` closures may still implement [`Fn`] or [`FnMut`], even though
956+ /// they capture variables by `move`. This is because the traits implemented by
957+ /// a closure type are determined by *what* the closure does with captured
958+ /// values, not *how* it captures them:
959+ ///
960+ /// ```rust
961+ /// fn create_fn() -> impl Fn() {
962+ /// let text = "Fn".to_owned();
963+ ///
964+ /// move || println!("This is a: {}", text)
965+ /// }
966+ ///
967+ /// let fn_plain = create_fn();
968+ ///
969+ /// fn_plain();
970+ /// ```
971+ ///
960972/// `move` is often used when [threads] are involved.
961973///
962974/// ```rust
You can’t perform that action at this time.
0 commit comments