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