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 consumes it's possible Exception using try catch block and constructs Expected in regards of the result.
auto fn(int v) { if (v == 42) throw new Exception("don't panic"); return v; } assert(consume!fn(1) == 1); assert(consume!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 consumes it's possible Exception using try catch block and constructs Expected in regards of the result.