[][src]Macro stdbench::execute

macro_rules! execute {
    ($cmd:expr; $errmsg:expr) => { ... };
}

Executes a $cmd, checks for results, and returns an error with $errmsg message. It is designed to be similar to ? operator, removing bulky boilerplate from functions that execute many consecutive commands.

This macro will return error in one of the two cases:

This macro is intended to be used in simple cases when we do not want to capture the output or learn more about exit status, since the only feedback we get is the error message passed at the call site.

Example

extern crate boolinator;
use boolinator::Boolinator;
fn f() -> Result<(), Error> {
    execute!(Command::new("ls"); "couldn't ls");
    execute!(Command::new("cat").args(&["some_file"]); "couldn't cat");
    Ok(())
}

match f() {
    Ok(()) => println!(),
    Err(err) => println!("Here's what went wrong"),
}