4 ms·
Another way to see the benefit of this approach is that if you have a memory violation, then you only have to look in the unsafe blocks. So, yes the less numer
by iTokio 2y ago
Another way to see the benefit of this approach is that if you have a memory violation, then you only have to look in the unsafe blocks.
So, yes the less numerous they are, the more you gain from it.
- inahga 2y ago> Another way to see the benefit of this approach is that if you have a memory violation, then you only have to look in the unsafe blocks. Not really. Safety is non-local. It is possible to break unsafe code by feeding inputs from safe Rust that don't uphold the invariants that make the unsafe code safe. So it's not enough to look in the unsafe blocks--you have to consider the all the contexts that invoke the unsafe code. See https://doc.rust-lang.org/nomicon/working-with-unsafe.html https://doc.rust-lang.org/nomicon/working-with-unsafe.html, and https://notgull.net/cautionary-unsafe-tale/ https://notgull.net/cautionary-unsafe-tale/ for a practical example.