3 ms·
>Rust references semantically closer to being mutexes evaluated at compile-time This is brilliant. Do you have a blog(or anything that comes close to it) about
by chalcolithic 5y ago
>Rust references semantically closer to being mutexes evaluated at compile-time
This is brilliant. Do you have a blog(or anything that comes close to it) about Rust?
- dystroy 5y agoThis is indeed interesting. I usually start to explain "mut" as meaning "exclusive", and I hadn't seen the now obvious relation with "mutex". "mut is for mutex".
- Measter 5y agoI've been thinking along similar lines for a little while. For me, it's not about mutation, but unrestricted mutation. When a unique reference (&mut T) exists then the only possible way to even look at the data is through that unique reference. In that situation, there's no reason to have any restrictions on mutation, because nothing else can observe it. With shared references (&T), multiple parts of the program can access the data at the same time. If you mutate in that situation you can end up with memory corruption due to data races, so mutation has to be restricted to require runtime synchronization through RefCells, Mutexs, etc.