4 ms·
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
by steveklabnik 1y ago
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.
- tialaramex 1y agoThe 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.
- CCs 1y agoScala has it like this since day one. Tried to convince D to adopt it, but was unsuccessful. Glad that C++ eventually got there…
- masklinn 1y agoIn most respect it's also "day 1" in rust, since it was added in 0.7 (https://github.com/alexcrichton/rust/commit/4f2f545ac2ce19034b138006e7ac76e502b3188b https://github.com/alexcrichton/rust/commit/4f2f545ac2ce1903...)
- anon-3988 1y agoNot 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.