6 ms·
But you can use code that introduces memory corruption. Plenty of crates make use of unsafe blocks.
by dleslie 4y ago
But you can use code that introduces memory corruption. Plenty of crates make use of unsafe blocks.
- dodobirdlord 4y agoUnnecessary use of unsafe blocks is stylistically discouraged in Rust, so there's a lot less code that has the potential to harbor a memory safety bug, which makes bugs both less likely to exist and easier to spot when doing a code audit before introducing a dependency on third-party code.
- woodruffw 4y agoOf course: you can call a C function that's unsound, and that unsoundness can make your surrounding Rust program unsound. This doesn't change the surrounding point however, which is Rust's philosophy of safeness by construction: if a particular piece of code is safe, then no safe (i.e., invariant-preserving) use of it can be unsafe. That alone makes Rust's security properties strictly better than those of C++, where even the modern safer paradigms can violate underlying invariants.