into-result 0.3.1

A simple convenience trait for converting something into a `Result` or `Option`
Documentation
  • Coverage
  • 0%
    0 out of 14 items documented0 out of 6 items with examples
  • Size
  • Source code size: 20.58 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • asterbloom

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.