I can't wait for more languages to simply not include null at all. It makes trying to spot them in static analysis and runtime checks much easier, because you no longer need either.
Given these two function signatures:
pub fn getUser() -> User
pub fn getMaybeUser() -> Option<User>
This code won't compile, because `getUser()` cannot return a `None`: pub fn foo() -> Option<String> {
let user = getUser()?;
return user.name
}
But this code will compile: pub fn foo2() -> Option<String> {
let user = getMaybeUser()?;
return Some(user.name)
}
(rust playground link: https://play.rust-lang.org/?version=stable&mode=debug&editio...)