Implicit conversion from 'Ok' to 'Result' type when returning functions
David Zhang via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 21 02:29:40 PDT 2017
On Sunday, 21 May 2017 at 09:15:56 UTC, Nicholas Wilson wrote:
> have free functions
>
> Result!(T, ErrorEnum) ok(T)(T t) { return Result(t); }
> Result!(T, ErrorEnum) error(T)(ErrorEnum e) { return
> Result(e); }
>
> then go
>
> if (!foo)
> return ok(42);
> else
> return error(Error.fooHappened);
Ah, I think you misread. ErrorEnum is a template type, like `T`.
There's no ErrorEnum enum specified.
More information about the Digitalmars-d-learn
mailing list