From 5b57dd6689a1f4246f934c21f337f9ffc0ca6bb3 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 15:39:48 +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 +++- 2 files changed, 7 insertions(+), 3 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(); } ```