What is the rationale behind enabling Nullable!T to be used as a regular T?

Elronnd elronnd at elronnd.net
Fri Feb 14 16:17:18 UTC 2020


On Friday, 14 February 2020 at 08:54:41 UTC, Adnan wrote:
> Nullable!T, as I understand is somewhat similar to Rust's 
> Option<T>. It's meant to be an alternative to sentinel value 
> based error checking.

Not exactly, as others have mentioned.  But there is 
https://github.com/moon-chilled/tenbots-opensource/blob/master/maybe.d (which originally comes from https://github.com/dkhasel/maybe-d, but I cleaned it up a bit).  At one point, I wrote a wrapper which would let you write a function with a return type of Maybe!T, but which actually returned objects of type T.  But that was a giant hack and not at all worth it.


More information about the Digitalmars-d mailing list