3 ms·
> You can write perfectly safe code in C where virtually everything is unsafe in the sense of the unsafe keyword. The key here: Rust SURFACE AS TYPES this info
by mamcx 5y ago
> You can write perfectly safe code in C where virtually everything is unsafe in the sense of the unsafe keyword.
The key here: Rust SURFACE AS TYPES this information.
Is similar to this piece of code (imagine is python):
sum(a,b)
what it actually do? WHO KNOWS. But this:
sum(a:int,b:int):int
is informative. And the "type system" can verify its use.
So "unsafe" is part of the type system, type checks that Rust use to COMMUNICATE and CHECK the use of code. So, if I, as user see this:
unsafe fn raw_memory(...)
I know the type system of Rust was bypassed and must TRUST the HUMAN know how correctly code what is inside.
---
The major advantage here, is that the blast area of this stuff is limited and for the rest of regular code, the type system verify the code and remove the need to manually inspect (and make tests!) for a lot of trivial (and not so much1) stuff.
Is a total game-changer, in special for a system language.