[OT] Some neat ideas from the Kotlin language

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 24 06:50:37 PST 2016


On 02/23/2016 09:58 AM, Xinok wrote:
>
> Option<T> is an enum type in Rust (i.e. algebraic data type). The Rust
> compiler forces you to check all possible cases so you can't use it
> improperly. So you would have to use something like pattern matching or
> "if let" to check the state.
>
> https://doc.rust-lang.org/book/match.html#matching-on-enums

Probably we can do the same in a library: never allow the value out of 
an Option, but provide a visitor with two aliases (ham/spam). There was 
a related PR in Phobos, wasn't there? -- Andrei


More information about the Digitalmars-d mailing list