Re:Fish (shell) porting to Rust from C++
by nyanpasu64 on Tuesday January 31, 2023 @04:21AM
(#34593061)
I find that Rust prefers to prevent programmers from committing undefined behavior, rather than giving them the tools required to achieve tasks, when these requirements come in conflict (unsafe code is built to allow implementing general functionality with unchecked code, but is more difficult to write without UB than the equivalent operations in safe Java or unsafe C++, partly because mutating a & or aliasing a &mut is instant UB)
Not safe in the presence of variant records (i.e. enums in Rust), since one pointer might be used to derive a pointer to a field of one variant, and the object might concurrently be switched to a different variant. This is why Cell<> only relies on explicit get and set methods in the general case, where the entire object gets replaced. It's a well-known problem in temporal safety.