Listing 20-17 should show an additional change. In the definition of the Worker struct, the thread field’s type changes from thread::JoinHandle<()> to thread::JoinHandle<mpsc::Receiver<Job>>, but the tutorial forgets to mention this, and Listing 20-17 doesn't feature that change (although it should). If the reader follows the book’s walkthrough step-by-step, then after implementing Listing 20-17, they encounter a different error than the book says they will encounter. The error predicted by the book is the one that would occur if Listing 20-17 did contain the additional change.
Suggested fix:
Modify Listing 20-17 so that, in the definition of the Worker struct, the thread field’s type changes from thread::JoinHandle<()> to thread::JoinHandle<mpsc::Receiver<Job>>.
A similar issue exists in Listing 20-18. The tutorial says the code there will compile, but it doesn't, because the type of thread in Worker has not been updated to match the rest of the new code.
main
branch to see if this has already been fixed, in this file:URL to the section(s) of the book with this problem:
https://rust-book.cs.brown.edu/ch20-02-multithreaded.html
Description of the problem:
Listing 20-17 should show an additional change. In the definition of the
Worker
struct, thethread
field’s type changes fromthread::JoinHandle<()>
tothread::JoinHandle<mpsc::Receiver<Job>>
, but the tutorial forgets to mention this, and Listing 20-17 doesn't feature that change (although it should). If the reader follows the book’s walkthrough step-by-step, then after implementing Listing 20-17, they encounter a different error than the book says they will encounter. The error predicted by the book is the one that would occur if Listing 20-17 did contain the additional change.Suggested fix:
Modify Listing 20-17 so that, in the definition of the
Worker
struct, thethread
field’s type changes fromthread::JoinHandle<()>
tothread::JoinHandle<mpsc::Receiver<Job>>
.