2 ms·
This is not true. Unsafe only disables a few safety features. There are still a bunch left on so unsafe rust is still more safety checked than C.
by Polylactic_acid 6y ago
This is not true. Unsafe only disables a few safety features. There are still a bunch left on so unsafe rust is still more safety checked than C.
- Jhsto 6y agoCare to elaborate? What are such safety features?
- pizza234 6y agoThe only unsafe functionality the author describes is the unchecked array access. Based on that (which may be incomplete, of course), the borrow checker is a safety feature that is active.
- Ygg2 6y agoThe grandparent is wrong. Unsafe doesn't disable safety functions. From the big book of Rust Unsafety: The only things that are different in Unsafe Rust are that you can: - Dereference raw pointers - Call unsafe functions (including C functions, compiler intrinsics, and the raw allocator) - Implement unsafe traits - Mutate statics - Access fields of unions https://doc.rust-lang.org/stable/nomicon/what-unsafe-does.html https://doc.rust-lang.org/stable/nomicon/what-unsafe-does.ht... The point is, unsafely calling `get_unchecked` is what's bypassing the range check feature. Not Unsafe itself.