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

#1640 in Rust patterns

Download history 135/week @ 2024-07-22 113/week @ 2024-07-29 120/week @ 2024-08-05 141/week @ 2024-08-12 115/week @ 2024-08-19 112/week @ 2024-08-26 119/week @ 2024-09-02 226/week @ 2024-09-09 378/week @ 2024-09-16 557/week @ 2024-09-23 422/week @ 2024-09-30 385/week @ 2024-10-07 260/week @ 2024-10-14 247/week @ 2024-10-21 300/week @ 2024-10-28 273/week @ 2024-11-04

1,142 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