2 ms·
But how can an interface be considered safe if it actually isn't? I thought the Rust compiler guarantees safety of everything marked a such?
by teiferer 5mo ago
But how can an interface be considered safe if it actually isn't? I thought the Rust compiler guarantees safety of everything marked a such?
- gpm 5mo agoIt doesn't. The rust compiler exposes a rich type system by which the programmer can make safe abstractions around unsafe code that can't be misused, but it doesn't (and fairly fundamentally can't, thanks to Rice's theorem) verify that people who write unsafe code and purport to have made safe abstractions actually did so.
- andy12_ 5mo agoTo make performant code sometimes requires implementing or using "unsafe" functions (it's not obligatory, and a lot of projects don't use them; but it was probably needed to map Bun's behavior 1 to 1). Those require upholding some invariants that cannot be checked by the compiler. The compiler basically goes "I trust you on this one, programmer. If you fuck this up, unsafe behavior can propagate to the rest of the code".