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

> article authors are surprised the unsafe keyword is not required

The often surprising part of raw pointers to system programmers newly dabbling in Rust is that every operation on them is safe, except for deref. You can freely take addresses and do pointer arithmetic on them without having to deal with unsafe, and only have to tell the compiler that you know what you are doing when you either load or store something through them.



That's... simply not true. Pointer arithmetic is not, in general, safe. Example: https://doc.rust-lang.org/std/primitive.pointer.html#method....


Eh... the ptr::add function exists if you want to make extra promises to the compiler to let it optimize better, but if you don't a safe version exists: https://doc.rust-lang.org/std/primitive.pointer.html#method....




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

Search: