@@ -987,13 +987,13 @@ mod mod_keyword {}
987987/// Capture a [closure]'s environment by value.
988988///
989989/// `move` converts any variables captured by reference or mutable reference
990- /// to owned by value variables .
990+ /// to variables captured by value.
991991///
992992/// ```rust
993- /// let capture = "hello" ;
994- /// let closure = move || {
995- /// println!("rust says {}", capture);
996- /// };
993+ /// let data = vec![1, 2, 3] ;
994+ /// let closure = move || println!("captured {:?} by value", data);
995+ ///
996+ /// // data is no longer available, it is owned by the closure
997997/// ```
998998///
999999/// Note: `move` closures may still implement [`Fn`] or [`FnMut`], even though
@@ -1004,31 +1004,29 @@ mod mod_keyword {}
10041004/// ```rust
10051005/// fn create_fn() -> impl Fn() {
10061006/// let text = "Fn".to_owned();
1007- ///
10081007/// move || println!("This is a: {}", text)
10091008/// }
10101009///
10111010/// let fn_plain = create_fn();
1012- ///
10131011/// fn_plain();
10141012/// ```
10151013///
10161014/// `move` is often used when [threads] are involved.
10171015///
10181016/// ```rust
1019- /// let x = 5 ;
1017+ /// let data = vec![1, 2, 3] ;
10201018///
10211019/// std::thread::spawn(move || {
1022- /// println!("captured {} by value", x )
1020+ /// println!("captured {:? } by value", data )
10231021/// }).join().unwrap();
10241022///
1025- /// // x is no longer available
1023+ /// // data was moved to the spawned thread, so we cannot use it here
10261024/// ```
10271025///
10281026/// `move` is also valid before an async block.
10291027///
10301028/// ```rust
1031- /// let capture = "hello";
1029+ /// let capture = "hello".to_owned() ;
10321030/// let block = async move {
10331031/// println!("rust says {} from async block", capture);
10341032/// };
0 commit comments