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