6 ms·
> allows you This is where the rubber hits the road. Rust does not allow you to do this, in the sense that this is possibly undefined behavior. That "possibly"
by steveklabnik 2y ago
> allows you
This is where the rubber hits the road. Rust does not allow you to do this, in the sense that this is possibly undefined behavior. That "possibly" is why the compiler allows you to write this code, because by saying "unsafe", you are promising that this specific arbitrary address is legal for you to write to. But that doesn't mean that it's always legal to do so.
- timschmidt 2y agoThe compiler won't allow you to compile such code without the unsafe. The unsafe is *you* promising the compiler that *you* have checked to ensure that the address will always be legal. So that the compiler will allow you to compile the code.
- steveklabnik 2y agoRight, I'm saying "allow" has two different connotations, and only one of them, the one that you're talking about, applies.
- timschmidt 2y agoI gotcha. I misread and misunderstood. Yes, we agree.