On Wednesday, 14 February 2018 at 15:14:24 UTC, Meta wrote:

I think the best way to do this is to implement `map` for your optional type.

Optional!U map(U, alias f)()
    return empty? no!U : some!U(f(t));

Optional!int a = 3;
auto b = a.map!(v => cast(float)v);
assert(is(typeof(b) == Optional!float));

Ooh yes, of course! Thank you :)

Reply via email to