From df19210b22170fb3c346a388896ff2b07555d3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B6=80=EC=A2=85=EB=AF=BC?= Date: Sat, 2 Dec 2023 16:03:24 +0900 Subject: [PATCH] Fix incorrect source in 16.1 In the book, I should get a compilation error, but the source now passes compilation. modifies the source as in the book. --- .../ch16-fearless-concurrency/listing-16-05/src/main.rs | 6 ++++-- nostarch/chapter16.md | 4 +++- src/ch16-01-threads.md | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) 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}} ```