News for hackers. Stuff that matters.
Re:What Is Rust's Unsafe? (2019) by Dylan16807 on Monday April 11, 2022 @03:59AM (#30985897)
I think it depends on the kind of invariant. If it leads to undefined behavior that wouldn't already be possible, then mark it unsafe or change the unsafe code to eliminate it. If it just makes it act badly, like dropping a node, that's likely not a good place for unsafe.

Or more simply: Worry about all kinds of undefined behavior. That makes many issues easier to find, and you don't need to chain on additional logic to figure out how it might corrupt memory.

There are no comments on this comment yet.