2 ms·
In Rust, when you move out of a variable, that variable is now effectively out-of-scope; trying to access it will result in a compile error. Mutability in Rust
by NobodyNada 2y ago
In Rust, when you move out of a variable, that variable is now effectively out-of-scope; trying to access it will result in a compile error.
Mutability in Rust is an attribute of a location; not a value, so you can indeed move a value from an immutable location into a mutable one, thus "dropping immutability". (But you can only move out of a location that you have exclusive access to -- you can't move out of an & reference, for example -- so the effect is purely local.)
- dataflow 2y agoYeah that sounds about like what I expected. Thanks!