News for hackers. Stuff that matters.
Re:Thread Safety in C++ and Rust by Matumio on Sunday December 19, 2021 @04:09AM (#29612490)
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.

Re:Thread Safety in C++ and Rust by afiori on Sunday December 19, 2021 @04:36AM (#29612595)
to 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