File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -943,8 +943,7 @@ mod mod_keyword {}
943943/// Capture a [closure]'s environment by value.
944944///
945945/// `move` converts any variables captured by reference or mutable reference
946- /// to owned by value variables. The three [`Fn` trait]'s mirror the ways to capture
947- /// variables, when `move` is used, the closures is represented by the `FnOnce` trait.
946+ /// to owned by value variables.
948947///
949948/// ```rust
950949/// let capture = "hello";
@@ -953,6 +952,23 @@ mod mod_keyword {}
953952/// };
954953/// ```
955954///
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+ ///
956972/// `move` is often used when [threads] are involved.
957973///
958974/// ```rust
You can’t perform that action at this time.
0 commit comments