|
|
|
|
|
by wuch
3288 days ago
|
|
No, those are Rust specific things.
For example, aliasing mutable references in C++ is potentially dangerous, but not undefined behaviour per se. Regarding making a "really safe" data structure, this is quite tricky question.
Safety means quite different things in those communities.
Moreover those different concepts of safety are not readily transferable between languages, at least not in useful sense. In Rust you would say that data structure is safe if it doesn't cause undefined behaviour when used without any unsafe user-code.
Essentially once you write a safe data structure the safety is enforced by a compiler, even in a presence of malicious user-code (as long as it avoids unsafe blocks of code).
In C++ on the other hand, a user would have only themselves to blame if they broke a precondition expressed somewhere in a documentation and caused undefined-behaviour. This is exactly why I would postulate that writing correct data structure in Rust, as opposed to say C++, may require more effort.
For similar reasons using dependent types doesn't make programming any easier.
Of course, this may turn out to be a worthy investment in the long run. |
|