future-result 0.1.0

An ideomatic way of mapping a Result to a Future of Result
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented3 out of 4 items with examples
  • Size
  • Source code size: 21.09 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • IovoslavIovchev

future-result

A Rust crate that provides an ideomatic way of mapping a Result to a Future of Result.

Example usage

use future_result::FutureResult;

async fn add_1(x: u32) -> u32 {
    x + 1
}

fn main() {
    let fut = async {
        let ok: Result<u32, ()> = Ok(41);
        let ok = ok.then_map(add_1).await;

        assert_eq!(Ok(42), ok);

        // ...

        let err: Result<(), u32> = Err(9);
        let err = err.then_map_err(add_1).await;

        assert_eq!(Err(10), err);
    };

    futures::executor::block_on(fut);
}