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(); } ``` diff --git a/src/ch16-01-threads.md b/src/ch16-01-threads.md index cfdd0c7066..e6bb0a122e 100644 --- a/src/ch16-01-threads.md +++ b/src/ch16-01-threads.md @@ -247,7 +247,7 @@ should borrow the values. The modification to Listing 16-3 shown in Listing Filename: src/main.rs -```rust +```rust,ignore,does_not_compile {{#rustdoc_include ../listings/ch16-fearless-concurrency/listing-16-05/src/main.rs}} ```