Skip to content

Commit f7663d1

Browse files
eddypEddy Petrisor
authored and
Eddy Petrisor
committed
ch15-02-deref: Improve explanation on immut-to-mut
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>
1 parent f643a97 commit f7663d1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ch15-02-deref.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ never coerce to mutable references. Because of the borrowing rules, if you have
375375
a mutable reference, that mutable reference must be the only reference to that
376376
data (otherwise, the program wouldn’t compile). Converting one mutable
377377
reference to one immutable reference will never break the borrowing rules.
378-
Converting an immutable reference to a mutable reference would require that
379-
there is only one immutable reference to that data, and the borrowing rules
380-
don’t guarantee that. Therefore, Rust can’t make the assumption that converting
381-
an immutable reference to a mutable reference is possible.
378+
Converting an immutable reference to a mutable reference would require that the
379+
initial immutable reference is the only immutable reference to that data, but
380+
the borrowing rules don’t guarantee that. Therefore, Rust can’t make the
381+
assumption that converting an immutable reference to a mutable reference is
382+
possible.

0 commit comments

Comments
 (0)