3 ms·
This made me scratch my head: > Even in a language like Rust, which has not yet implemented mutable aliasing (an oft-requested feature stuck at the RFC stage)
by codeflo 2y ago
This made me scratch my head:
> Even in a language like Rust, which has not yet implemented mutable aliasing (an oft-requested feature stuck at the RFC stage)
Disallowing mutable aliasing is in fact the whole point of Rust. Perhaps it’s “requested” by people still learning the language? Is the “not yet implemented” part meant as irony? Does the author mean something else?
- sondr3 2y agoThis also made me scratch my beard, but I think he maybe means allowing multiple mutable references to a variable when the compiler can prove that nothing bad happens. It's something a bunch of people have been trying to solve with different models, the most recent I know of is Tree Borrows [1]. [1]: https://www.ralfj.de/blog/2023/06/02/tree-borrows.html https://www.ralfj.de/blog/2023/06/02/tree-borrows.html
- Georgelemental 2y agoTree Borrows is a model of `unsafe` code (for example using raw pointers), it is not a proposal to change what the safe Rust borrow checker accepts.
- ChrisSD 2y agoAnd it has mutable aliasing via `UnsafeCell`[0] which, as the name says, is unsafe. But safe wrappers can be built around it, such as `Cell`[1]. Or you can just use raw pointers and take safety into your own hands. [0]: https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html [1]: https://doc.rust-lang.org/std/cell/struct.Cell.html https://doc.rust-lang.org/std/cell/struct.Cell.html