3 ms·
"safely abstracting `unsafe`" is the important concept with respect to rust and it's use of `unsafe`. `unsafe` occurs in rust source code where the author of s
by codys 6y ago
"safely abstracting `unsafe`" is the important concept with respect to rust and it's use of `unsafe`.
`unsafe` occurs in rust source code where the author of some code needs to do things in a way that can't be directly proven to the compiler to be safe. These include things like calling C functions and ASM code (both cases where we can't infer all the information necessary to ensure safety). The author of the unsafe code then provides an "safe" abstraction around the unsafety that ensures that when one uses the "safe" interface, no undefined behavior occurs.
At the lowest level there is always some unsafety: system calls, libc function invocations, asm, modifying various memory mapped registers. What rust provides vs C or C++ is effective isolation of the unsafety.