Skip to main content

assert_match_result

Macro assert_match_result 

Source
macro_rules! assert_match_result {
    ($current:expr) => { ... };
    ($current:expr, $msg:expr) => { ... };
}
Expand description

Assert for a Result<T, E> value. If the value is a type of Ok(_) the result is Ok(()). If the value is a type of Err(_) the result is a type of Err(&str).

§Arguments

  • $current - The result to test to.
  • $msg - Optional specific message error.

§Returns

A type of Result<(), &str> for this assertion.

§Examples

use utmt::assert_match_result;
use utmt::facility_match_values;  // Warning: specific to doctest

let result = assert_match_result!(Ok::<i32, &str>(6));
assert_eq!(result, Ok(()));
use utmt::assert_match_result;
use utmt::facility_match_values;  // Warning: specific to doctest

let result = assert_match_result!(Err::<(), &str>("Foo"), "It's failed");
assert_eq!(result, Err("It's failed"));