lift-fail

Crates.iolift-fail
lib.rslift-fail
version0.1.0
sourcesrc
created_at2018-02-22 23:45:09.475985
updated_at2018-02-22 23:45:09.475985
descriptionA library to handle `failure` in an iterable collection.
homepagehttps://github.com/mgattozzi/lift-fail
repositoryhttps://github.com/mgattozzi/lift-fail
max_upload_size
id52448
size25,563
Michael Gattozzi (mgattozzi)

documentation

https://docs.rs/lift-fail

README

lift-fail

A library to handle failure in an iterable collection.

About

Sometimes you'll want to do something where a lot of things can fail at once, usually when doing parallel work. What if some things fail? What if some don't? What if it's all good? This library helps handle that if you use the failure crate to handle errors.

Getting Started

Put this in your Cargo.toml:

[dependencies]
lift-fail = "0.1"

Then in your lib.rs or main.rs file:

extern crate lift_fail

Then wherever you need it:

use lift_fail::lift_fail;

Here's a basic use case:

#[macro_use] extern crate failure;
extern crate lift_fail;

use lift_fail::lift_fail;

fn main() {
    let example_vec = vec![
        Ok(1),
        Err(format_err!("Uh oh")),
        Ok(2),
        Err(format_err!("Oh no")),
    ];

    match lift_fail(example_vec) {
        // We have errors in our vec so we know we won't get a vector of just the
        // correct values. We're lifting up the errors into one.
        Ok(_) => unreachable!(),
        Err(e) => println!("{}", e.cause()),
    }
}

Examples

See the examples directory to see how to use the library is used in other ways.

Contributing

See CONTRIBUTING.md for more information.

License

Licensed under either of

at your option.

Licensing

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.

Commit count: 0

cargo fmt