OutputOkExt

Trait OutputOkExt 

Source
pub trait OutputOkExt
where Self: Sized,
{ // Required method fn ok(self) -> OutputResult; // Provided methods fn unwrap(self) -> Output { ... } fn unwrap_err(self) -> OutputError { ... } }
Expand description

Converts a type to an OutputResult.

This is for example implemented on std::process::Output.

§Examples

use assert_cmd::prelude::*;

use std::process::Command;

let result = Command::new("echo")
    .args(&["42"])
    .ok();
assert!(result.is_ok());

Required Methods§

Source

fn ok(self) -> OutputResult

Convert an Output to an OutputResult.

§Examples
use assert_cmd::prelude::*;

use std::process::Command;

let result = Command::new("echo")
    .args(&["42"])
    .ok();
assert!(result.is_ok());

Provided Methods§

Source

fn unwrap(self) -> Output

Unwrap a Output but with a prettier message than .ok().unwrap().

§Examples
use assert_cmd::prelude::*;

use std::process::Command;

let output = Command::new("echo")
    .args(&["42"])
    .unwrap();
Source

fn unwrap_err(self) -> OutputError

Unwrap a Output but with a prettier message than ok().err().unwrap().

§Examples
use assert_cmd::prelude::*;

use std::process::Command;

let err = Command::new("a-command")
    .args(&["--will-fail"])
    .unwrap_err();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OutputOkExt for &mut Command

Source§

impl OutputOkExt for Output

Implementors§

Source§

impl OutputOkExt for &mut assert_cmd::cmd::Command