Skip to main content

assert_match_option

Macro assert_match_option 

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

Assert the Option<T> value. If the value is Some(...) return Ok(()), otherwise a Err value.

§Arguments

  • $current- Current value for matching option,
  • $msg- (Optional) Specific message error.

§Returns

A Result<(), &str> as the test result.

§Examples

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

let value = Some("Hello");
let result = assert_match_option!(value);

assert_eq!(result, Ok(()));
use utmt::assert_match_option;
use utmt::facility_match_values;  // Warning: specific to doctest

let result = assert_match_option!(None::<i16>, "None found");

assert_eq!(result, Err("None found"));