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

When we added the equivalent to Rust, it was a bit controversial. But the idea of "an optional type is a list with zero or one items in it" is much more normal in functional places, and so a lot of people like it quite a bit too.


The fun thing is that the original design (N3527 over a decade ago) for std::optional specifically says it's not the container with exactly zero or one items, whereas I believe Rust's Option never made this claim and so recognising this isn't a U-turn.


Scala has it like this since day one. Tried to convince D to adopt it, but was unsuccessful. Glad that C++ eventually got there…


In most respect it's also "day 1" in rust, since it was added in 0.7 (https://github.com/alexcrichton/rust/commit/4f2f545ac2ce1903...)


Not so fun for me. I wasted a considerable amount of time debugging an issue like this because i had returned option of vec.

Granted i have learnt better and should probably create an enum that explicitly describe what all the different states represent.




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

Search: