#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

#1391 in Rust patterns

Download history 107/week @ 2023-11-26 82/week @ 2023-12-03 83/week @ 2023-12-10 109/week @ 2023-12-17 153/week @ 2023-12-24 172/week @ 2023-12-31 162/week @ 2024-01-07 118/week @ 2024-01-14 127/week @ 2024-01-21 110/week @ 2024-01-28 121/week @ 2024-02-04 120/week @ 2024-02-11 171/week @ 2024-02-18 125/week @ 2024-02-25 136/week @ 2024-03-03 79/week @ 2024-03-10

524 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