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

#1848 in Rust patterns

Download history 178/week @ 2024-11-18 195/week @ 2024-11-25 287/week @ 2024-12-02 249/week @ 2024-12-09 320/week @ 2024-12-16 301/week @ 2024-12-23 258/week @ 2024-12-30 502/week @ 2025-01-06 483/week @ 2025-01-13 383/week @ 2025-01-20 288/week @ 2025-01-27 488/week @ 2025-02-03 442/week @ 2025-02-10 612/week @ 2025-02-17 421/week @ 2025-02-24 363/week @ 2025-03-03

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