book icon indicating copy to clipboard operation
book copied to clipboard

Ch 21.02 - listings missing required code

Open rickrain opened this issue 5 months ago • 1 comments

This PR updates listings 21-17 and 21-18 to show changes that were necessary to the Worker struct.

In listing 21-17, unless you also update the type for the Worker::thread field, you will get compiler errors about mismatched types, in addition to, the ownership errors that were expected. Since these additional errors were not mentioned in the text, the reader should see that the struct needed updating too. It's clear from the text that the intent was to focus on the ownership/borrowing errors - this change accomplishes that.

Note: I also updated the markdown text in ch21-02-multithreaded.md to explain the necessary change in the struct.

Similarly, in listing 21-18, the type for the Worker::thread field needs to be updated with the new smart pointer declaration, otherwise it won't compile. I didn't add any text to the markdown for this change, since the explanation from 21-17 is already understood.

rickrain avatar May 05 '25 22:05 rickrain