|
Too bad Rust doesn't have union types (aka adhoc / anonymous unions) yet. Without them, using typed errors is very clumsy. Optimally, you would write the following code: fn foo(r1: Result<i32, Error1>, r: Result<i32, Error2>) {
let i1 = r1?;
let i2 = r2?;
// ...
}
and Rust would infer the return type to be Result<String, Error1 | Error2>
without having to do any extra definitions or conversions. |