Closed k-yang closed 8 months ago
Fortunately, Aquascope is telling you the truth, that this program is not valid. Here's a playground link.
On line 3, n
is a shared reference, meaning that memory behind the reference cannot be mutated. Aquascope indicates this by saying *n
gains read (R
) permission but neither write (W
) nor own (O
) permission. This leads to the permissions violation on line 4.
However, the interpreted program shows that it runs without error. That is, if Rust did allow the program to run it doesn't crash. (Note that we bypass compiler errors to interpret the program, but rustc would not provide a binary for this program.)
For more on references and borrowing, please refer to Chapter 4 in The Rust Book Experiment.
The following is a valid Rust program (compiles without errors). Why doesn't the
*n
path have the write permission?