into-result

Crates.iointo-result
lib.rsinto-result
version0.3.1
sourcesrc
created_at2019-07-26 20:18:43.449005
updated_at2020-03-09 23:29:52.973581
descriptionA simple convenience trait for converting something into a `Result` or `Option`
homepage
repositoryhttps://github.com/francesca64/into-result
max_upload_size
id151858
size20,588
Francesca Lovebloom (francesca64)

documentation

https://docs.rs/into-result

README

into-result

crates.io badge docs.rs badge Travis badge

A simple convenience trait for converting something into a Result or Option.

Out of the box, this gives you improved error handling for Command::output Command::spawn, and Command::status. These methods only return Err if the process fails to spawn; further handling is required to check if the command has a successful exit status. IntoResult does that handling for you, folding both types of failure into one Result:

use into_result::{IntoResult as _};
use std::process::Command;

Command::new("ls")
    .spawn()
    .into_result()
    .expect("either failed to spawn command, or command returned non-zero exit status");

You can run the example to see what this looks like in practice.

into-result also has no_std support via no-default-features. You'll still get the IntoResult trait and an impl for bool.

Commit count: 0

cargo fmt