diff --git a/listings/ch21-web-server/listing-21-17/src/lib.rs b/listings/ch21-web-server/listing-21-17/src/lib.rs index d764879e5d..3758bbbb3e 100644 --- a/listings/ch21-web-server/listing-21-17/src/lib.rs +++ b/listings/ch21-web-server/listing-21-17/src/lib.rs @@ -43,16 +43,11 @@ impl ThreadPool { // ANCHOR: here } -// --snip-- - -// ANCHOR_END: here - struct Worker { id: usize, - thread: thread::JoinHandle<()>, + thread: thread::JoinHandle>, } -// ANCHOR: here impl Worker { fn new(id: usize, receiver: mpsc::Receiver) -> Worker { let thread = thread::spawn(|| { diff --git a/listings/ch21-web-server/listing-21-18/src/lib.rs b/listings/ch21-web-server/listing-21-18/src/lib.rs index 7df8ed35a5..67ab96f403 100644 --- a/listings/ch21-web-server/listing-21-18/src/lib.rs +++ b/listings/ch21-web-server/listing-21-18/src/lib.rs @@ -52,15 +52,11 @@ impl ThreadPool { // ANCHOR: here } -// --snip-- - -// ANCHOR_END: here struct Worker { id: usize, - thread: thread::JoinHandle<()>, + thread: thread::JoinHandle>>>, } -// ANCHOR: here impl Worker { fn new(id: usize, receiver: Arc>>) -> Worker { // --snip-- diff --git a/src/ch21-02-multithreaded.md b/src/ch21-02-multithreaded.md index c89244e26d..1d5cf58a94 100644 --- a/src/ch21-02-multithreaded.md +++ b/src/ch21-02-multithreaded.md @@ -515,7 +515,9 @@ closure. The code in Listing 21-17 won’t quite compile yet. We’ve made some small and straightforward changes: we pass the receiver into -`Worker::new`, and then we use it inside the closure. +`Worker::new`, and then we use it inside the closure. This causes the type returned +from `thread::spawn` to change too. So, we also updated the type for the `thread` +field in the `Worker` struct. When we try to check this code, we get this error: