#exit-status #as-result #into-result

as-result

Traits for converting types which may be interpreted as or into a result

3 unstable releases

0.2.1 Dec 20, 2019
0.2.0 Dec 12, 2019
0.1.0 Dec 11, 2019

#518 in Rust patterns

Download history 159/week @ 2022-06-01 162/week @ 2022-06-08 166/week @ 2022-06-15 176/week @ 2022-06-22 130/week @ 2022-06-29 162/week @ 2022-07-06 182/week @ 2022-07-13 186/week @ 2022-07-20 153/week @ 2022-07-27 176/week @ 2022-08-03 146/week @ 2022-08-10 150/week @ 2022-08-17 160/week @ 2022-08-24 155/week @ 2022-08-31 197/week @ 2022-09-07 141/week @ 2022-09-14

676 downloads per month
Used in apt-cmd

MIT/Apache

7KB
74 lines

as-result

Crates.io

Rust crate which provides the AsResult<T, E> and IntoResult<T, E> traits.

Supported Types

By default, the following types from the standard library have implementations of these traits:

Example

Common when spawning commands is the desire to convert the exit status into a result:

use as_result::*;
use std::process::Command;

Command::new("/bin/echo")
    .arg("hello world")
    .status()
    .and_then(IntoResult::into_result)
    .unwrap();

Command::new("/bin/echo")
    .arg("hello world")
    .status()
    .unwrap()
    .into_result()
    .unwrap();

Command::new("/bin/echo")
    .arg("hello world")
    .status()
    .map_result()
    .unwrap()

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.

No runtime deps