> It seems as though there is this common misconception that Rust does not have a concept of null.
I don't think that's quite relevant, though. Rust doesn't have a concept of nulls like like Java, Javascript, Python, etc do in which just about any variable might contain a value or null. Rust certainly doesn't have that.
Re:Why nullable types?
by ibraheemdev on Tuesday December 08, 2020 @08:33AM
(#25344764)
I would not say that it is not relevant. Raw pointers are a fundamental part of the language. It is just that Rust abstracts over them so that many users do not have to worry about them.
I see your point though.
I don't think people mean it doesn't have a raw null pointer. Normally it's about a null object reference that you can assign to (almost) anything like Java's / c's null.
Of course Rust has a null pointer type. Otherwise, it wouldn’t really be a systems programming language :)
But most users would rarely if ever need to use that type. Option<T> is how Rust deals with optional/nullable values.
Note that nowadays the preferred way to handle null pointers in APIs is the `Option<NonNull>` type. This unfortunately wasn't available in Rust 1.0.
It seems as though there is this common misconception that Rust does not have a concept of null. Rust does have null pointers [1]! The reason many people do not see null often is because working with and dereferencing raw pointers is an unsafe operation
1: https://doc.rust-lang.org/std/ptr/fn.null.html