Re:Such a Little Thing: The Semicolon in Rust
by dagw on Friday October 19, 2012 @05:01AM
(#4672778)
What if foo() could return nil in some cases?
[ Parent
| on HN ]
Re:Such a Little Thing: The Semicolon in Rust
by danieldk on Friday October 19, 2012 @07:54AM
(#4673098)
Then you need an algebraic data type having nil is one of its constructors, and that function returning that type.
AFAIK, Rust doesn't have nil. So, the closest thing is using the option type.
Re:Such a Little Thing: The Semicolon in Rust
by kibwen on Friday October 19, 2012 @08:47AM
(#4673254)
In Rust, nil is the name for the unit type (written as empty parentheses, like "()"), used whenever a function doesn't return anything meaningful. You're correct in that instead of null pointers it has the None variant of the Option enum.