// void { auto res = ok(); static assert(is(typeof(res) == Expected!(void, string))); assert(res); } // int { auto res = ok(42); static assert(is(typeof(res) == Expected!(int, string))); assert(res); assert(res.value == 42); } // string { auto res = ok("42"); static assert(is(typeof(res) == Expected!(string, string))); assert(res); assert(res.value == "42"); } // other error type { auto res = ok!bool(42); static assert(is(typeof(res) == Expected!(int, bool))); assert(res); assert(res.value == 42); }
Creates an Expected object from an expected value, with type inference.