3 ms·
It is not inherently a bad thing. In fact, it's very important for Rust to be able to accomplish its goals. As a systems language, we cannot dictate what we wis
by steveklabnik 10y ago
It is not inherently a bad thing. In fact, it's very important for Rust to be able to accomplish its goals. As a systems language, we cannot dictate what we wish the machine to be; it doesn't follow our rules.
Unsafe allows for three things: enable extending Rust's guarantees by allowing for humans to vouch for code, the ability to encapsulate these behaviors into a safe interface for users, and give them clear indicators of what to audit if and when they fail at it :).
It's also worth noting that "unsafe" doesn't mean "anything goes." It enables extra behaviors. Regular old references are still borrow checked inside an unsafe block; unsafe unlocks the ability to dereference a raw pointer. In this case, because you're getting a raw pointer from C, unsafe has to be used: Rust can't know if C is playing by the rules.
- quotemstr 10y ago> As a systems language, we cannot dictate what we wish the machine to be; it doesn't follow our rules. Except aborting on OOM. Rust's stdlib can have an opinion about that.
- steveklabnik 10y agoSure. Our opinion is that we like our decision here. Luckily, that's only the standard library, not the language. But, I have a feeling we've been down this road before...