Description
Hi,
first of all I've read your book (also bought the dead tree version just to keep it in my personal library) and I must say that you did a great job explaining basics of rust. Rust makes me feel dumb every time I deal with it but your book made thinks smoother for me. Great job!
Regarding PR #2108 and issue #1871
Since I wasn't really satisfied with explanation given in the book I had to dig in a little bit more and found out this post (thread already linked in #1871):
https://users.rust-lang.org/t/drop-semantics-and-temporary-value-lifetimes-in-while-let/30903/15
According to explanation found in that thread the match
and let
semantics differ which is the reason behind the mutex being released in one case and not in another. It doesn't have anything to do with the type of a loop. I think it would be good to mention for the future readers that it comes down to differing semantics of match and let but the explanation of the difference falls outside of the scope of this book or something along those lines.
Here is a link to the part of the book in question: https://doc.rust-lang.org/book/ch20-02-multithreaded.html