Re:Baby Steps: Slowly Porting Musl to Rust
by quotemstr on Sunday June 12, 2016 @01:35PM
(#11889211)
> 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.
Re:Baby Steps: Slowly Porting Musl to Rust
by steveklabnik on Sunday June 12, 2016 @01:36PM
(#11889212)
Sure. 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...
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.