main.rs
1 use std::thread; 2 3 fn main() { 4 let list = vec![1, 2, 3]; 5 println!("Before defining closure: {list:?}"); 6 7 thread::spawn(move || println!("From thread: {list:?}")) 8 .join() 9 .unwrap(); 10 }
1 use std::thread; 2 3 fn main() { 4 let list = vec![1, 2, 3]; 5 println!("Before defining closure: {list:?}"); 6 7 thread::spawn(move || println!("From thread: {list:?}")) 8 .join() 9 .unwrap(); 10 }