2 ms·
> Rust doesn't have nil/null values. I have to nitpick here: Rust raw pointers (https://doc.rust-lang.org/std/primitive.pointer.html https://doc.rust-lang.org/
by cesarb 4y ago
> Rust doesn't have nil/null values.
I have to nitpick here: Rust raw pointers (https://doc.rust-lang.org/std/primitive.pointer.html https://doc.rust-lang.org/std/primitive.pointer.html which does note "Working with raw pointers in Rust is uncommon") do have null values. It's not usually a problem since raw pointers can only be dereferenced in unsafe code; most of the time, you will be using a reference wrapped with an Option, which has the same size and same possible values (the compiler knows a reference is never null, so it uses the "missing" null value to represent the None variant of the Option enum).
- Lev1a 4y ago> since raw pointers can only be dereferenced in unsafe code Sure, and "unsafe" is not only a huge red flag but can and should be tightly scoped and can then be audited much easier than chasing around NPE through an entire Class or even codebase. Secondly, I've used Rust for a few years now and have NEVER needed to or thought of using raw pointers once. It's unnecessary for almost every single usecase I can think of except maybe OS or driver development but even then you can tightly control where "unsafe" uses pop up.