Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The 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.ht...

The point is, unsafely calling `get_unchecked` is what's bypassing the range check feature. Not Unsafe itself.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: