#exit-status #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

#1818 in Rust patterns

Download history 285/week @ 2025-09-11 208/week @ 2025-09-18 229/week @ 2025-09-25 188/week @ 2025-10-02 211/week @ 2025-10-09 232/week @ 2025-10-16 195/week @ 2025-10-23 158/week @ 2025-10-30 182/week @ 2025-11-06 141/week @ 2025-11-13 164/week @ 2025-11-20 158/week @ 2025-11-27 167/week @ 2025-12-04 169/week @ 2025-12-11 216/week @ 2025-12-18 133/week @ 2025-12-25

713 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