|
|
|
|
|
by pcwalton
4420 days ago
|
|
Yes, you can do it, with Cell and RefCell, though the former is restricted to POD types and the latter comes with some minor runtime overhead. Inherited mutability is not an unnecessary restriction from the point of view of memory safety. It's critical to Rust's ability to prevent iterator invalidation and related bugs at compile time. The fact that C++ doesn't do it is the source of many of its memory safety problems, such as dangling references and iterator invalidation. |
|
I had to look this acronym up. In case anybody else needs a definition:
https://en.wikipedia.org/wiki/Plain_Old_Data_Structures