3 ms·
Rust has the concept of "interior unsafe". The idea is that you build an abstraction and wrap away the unsafety. That abstraction has to be built defensively,
by Tobu 6y ago
Rust has the concept of "interior unsafe".
The idea is that you build an abstraction and wrap away the unsafety. That abstraction has to be built defensively, which is enabled by the type system enforcing very powerful invariants across the program. You can safely encode the way your structures may or may not be used across threads, enforce exclusive vs shared access, control mutability.
Unsafe is not a "do whatever" card, you use it with the rest of the language as one more tool that helps build safe programs.