1 // void 2 { 3 auto res = ok(); 4 static assert(is(typeof(res) == Expected!(void, string))); 5 assert(res); 6 } 7 8 // int 9 { 10 auto res = ok(42); 11 static assert(is(typeof(res) == Expected!(int, string))); 12 assert(res); 13 assert(res.value == 42); 14 } 15 16 // string 17 { 18 auto res = ok("42"); 19 static assert(is(typeof(res) == Expected!(string, string))); 20 assert(res); 21 assert(res.value == "42"); 22 } 23 24 // other error type 25 { 26 auto res = ok!bool(42); 27 static assert(is(typeof(res) == Expected!(int, bool))); 28 assert(res); 29 assert(res.value == 42); 30 }
Creates an Expected object from an expected value, with type inference.