Macro lib::assert_option_some_eq

source ·
macro_rules! assert_option_some_eq {
    ($a:expr, $b:expr $(,)?) => { ... };
    ($a:expr, $b:expr, $($message:tt)+) => { ... };
}
Expand description

Assert two expressions are Some(_) and their values are equal.

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

let a: Option<i8> = Option::Some(1);
let b: Option<i8> = Option::Some(1);
assert_option_some_eq!(a, b);

let a: Option<i8> = Option::Some(1);
let b: Option<i8> = Option::Some(2);
assert_option_some_eq!(a, b);
// assertion failed: `assert_option_some_eq!(a, b)`
//  a label: `a`,
//  a debug: `Some(1)`,
//  a inner: `1`,
//  b label: `b`,
//  b debug: `Some(2)`,
//  b inner: `2`

§Module macros