#exit-status #traits #command-output #convert #converting #type #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

#1503 in Rust patterns

Download history 201/week @ 2024-01-04 114/week @ 2024-01-11 117/week @ 2024-01-18 144/week @ 2024-01-25 103/week @ 2024-02-01 118/week @ 2024-02-08 152/week @ 2024-02-15 149/week @ 2024-02-22 128/week @ 2024-02-29 117/week @ 2024-03-07 135/week @ 2024-03-14 111/week @ 2024-03-21 126/week @ 2024-03-28 101/week @ 2024-04-04 116/week @ 2024-04-11 84/week @ 2024-04-18

439 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