Constructs Expected from the result of the provided function.
If the function is nothrow, it just returns it's result using Expected.
If not, then it uses try catch block and constructs Expected with value or error.
auto fn(int v) { if (v == 42) throw new Exception("don't panic"); return v; } assert(expected!fn(1) == 1); assert(expected!fn(42).error.msg == "don't panic");
See Implementation
Constructs Expected from the result of the provided function.
If the function is nothrow, it just returns it's result using Expected.
If not, then it uses try catch block and constructs Expected with value or error.