cognitive-engineering-lab / rust-book

The Rust Programming Language: Experimental Edition
https://rust-book.cs.brown.edu
Other
506 stars 82 forks source link

Possible error on Chapter 4.3 #96

Closed musjj closed 1 year ago

musjj commented 1 year ago

URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch04-03-fixing-ownership-errors.html#fixing-an-unsafe-program-copying-vs-moving-out-of-a-collection

Description of the problem: v should not lose read permission in second line.

Suggested fix: v should keep its read permission.

willcrichton commented 1 year ago

Hi, thanks for the issue. This is one of those technically-correct but confusing behaviors right now, an instance of cognitive-engineering-lab/aquascope#85. v loses read permissions because it is no longer live at that line. But if you extended the live range of v by reading it later, that would be totally fine. As mentioned in the linked issue, we're working on a clearer explanation of this idea!