Closed Yung-Beef closed 6 days ago
This is explained extensively in the section immediately preceding it, beginning with Implementing the Execute Method. Listing 20-19 shows defining the job as a Box<dyn FnOnce() + Send + 'static>
and creating a job
of that type and sending it with self.sender.send(job).unwrap();
, and then Listing 20-20 shows getting it in the receiver and using it.
URL to the section(s) of the book with this problem: https://doc.rust-lang.org/book/ch20-02-multithreaded.html
Description of the problem: This code block contains
job()
which seems to have appeared out of nowhere, and the text doesn't explain it. We never defined a job function, and it has a semicolon after it so the variable isn't being returned (and variables don't have parentheses after them anyways).Suggested fix: Explain why
job()
is there, what type it is, what it's doing, why it has parentheses and is followed by a semicolon.