diff --git a/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs b/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs index a6547dc4c1..41396f1c2a 100644 --- a/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs +++ b/listings/ch16-fearless-concurrency/listing-16-05/src/main.rs @@ -3,9 +3,11 @@ use std::thread; fn main() { let v = vec![1, 2, 3]; - let handle = thread::spawn(move || { + let handle = thread::spawn(|| { println!("Here's a vector: {:?}", v); }); + drop(v); // oh no! + handle.join().unwrap(); -} +} \ No newline at end of file diff --git a/nostarch/chapter16.md b/nostarch/chapter16.md index 7c5389e4f4..855026981e 100644 --- a/nostarch/chapter16.md +++ b/nostarch/chapter16.md @@ -389,10 +389,12 @@ use std::thread; fn main() { let v = vec![1, 2, 3]; - let handle = thread::spawn(move || { + let handle = thread::spawn(|| { println!("Here's a vector: {:?}", v); }); + drop(v); // oh no! + handle.join().unwrap(); } ```