News for hackers. Stuff that matters.
Re:Why Rust? [pdf] by dllthomas on Wednesday September 09, 2015 @07:10PM (#10195269)
The `value` you are returning has type T. T is not the same type as Optional<T>.

With AnimalMuppet's approach, you would need to return a pointer to a T (so, `&value` in something Cish). Note that this is not the same thing as a nullable reference in, for instance, C#.

`null or T` is a valid representation only when T is a non-nullable reference. It doesn't work when T is optional, and it also doesn't work when T is a primitive type, a struct, &c.

That said, there's obvious reasons it might be wanted an optimization where it's possible. For that specific case, `Just value` could be specialized to `value`, but that can be done by the compiler (akin to automatic unboxing, elsewhere).

There are no comments on this comment yet.