Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Rust Performance Pitfalls. Parent comment
So, unsafe Rust is a superset of safe Rust. Adding `unsafe` around some code lets you do four things:
* Dereferencing a raw pointer
* Calling an unsafe function or method
* Accessing or modifying a mutable static variable
* Implementing an unsafe trait
That's it. Nothing else changes, you get these additional abilities. This is very important, conceptually. Tons of other checks are still on, etc.
With that in mind,
> (What would happen if you put only code that could be verified by the compiler in an unsafe block?)
It would function identically.
There are no comments on this comment yet.
So, unsafe Rust is a superset of safe Rust. Adding `unsafe` around some code lets you do four things:
* Dereferencing a raw pointer
* Calling an unsafe function or method
* Accessing or modifying a mutable static variable
* Implementing an unsafe trait
That's it. Nothing else changes, you get these additional abilities. This is very important, conceptually. Tons of other checks are still on, etc.
With that in mind,
> (What would happen if you put only code that could be verified by the compiler in an unsafe block?)
It would function identically.