3 ms·
This was my biggest misconception when learning Rust. I was thinking "&mut" can modify data, so "&" cannot. Wrong. The "mut" keyword is not the opposite of "co
by Matumio 5y ago
This was my biggest misconception when learning Rust. I was thinking "&mut" can modify data, so "&" cannot. Wrong.
The "mut" keyword is not the opposite of "const" from C++. It's declaring that you have exclusive (unique) ownership at this moment.
- afiori 5y agoto be pedantic &mut is still a borrow not ownership, as another simplification the difference is that &mut can modify a value but must keep the borrowed value in a valid state, while full ownership can destroy a value