Skip to content

Commit

Permalink
ch15-02-deref: Improve explanation on immut-to-mut
Browse files Browse the repository at this point in the history
On a hypothetical immut-to-mut deref, the resulting mut ref should be
unique. The aliasing rules say a mutable reference should be the only
reference, so the initial immutable reference would have to be the only
one, which is not enforced. Change the phrasing so it expresses this
fact more clearly.

Signed-off-by: Eddy Petrișor <eddy.petrisor@gmail.com>
  • Loading branch information
eddyp committed Jul 13, 2019
1 parent f643a97 commit 0e1a92c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ch15-02-deref.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ a mutable reference, that mutable reference must be the only reference to that
data (otherwise, the program wouldn’t compile). Converting one mutable
reference to one immutable reference will never break the borrowing rules.
Converting an immutable reference to a mutable reference would require that
there is only one immutable reference to that data, and the borrowing rules
don’t guarantee that. Therefore, Rust can’t make the assumption that converting
an immutable reference to a mutable reference is possible.
the initial immutable reference is only one immutable reference to that data,
but the borrowing rules don’t guarantee that. Therefore, Rust can’t make the
assumption that converting an immutable reference to a mutable reference is
possible.

0 comments on commit 0e1a92c

Please sign in to comment.