multi_try crates.io badge

This crate allows combining multiple Result types, and returning either a tuple containing all of their results, or a Vec of any errors which occurred. It is useful when you want to provide an error message for all errors rather than simply returning the first error.

Generics are used to support Result<T, E> for any types of T and E. The ok types of the combined results are NOT required to be the same, but all of the error types must be the same.

Example

```rust struct A { b: Result, c: Result, d: Result, }

struct ValidatedA { b: i32, c: i64, d: f32, }

enum MyErr { FailedB, FailedC, FailedD, }

fn validate(a: A) -> Result> { let (b, c, d) = multitry::and( a.b, a.c ) .and(a.d) .intoresult()?;

Ok(ValidatedA { b, c, d })

} ```

Enabling nightly features

Enabling the nightly feature for multi_try allows removing the call to into_result before using the ? operator.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.