Macro assertables::assert_option_some_ne

source ·
macro_rules! assert_option_some_ne {
    ($a_option:expr, $b_option:expr $(,)?) => { ... };
    ($a_option:expr, $b_option:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a.is_some() and a.unwrap() is not equal to another.

  • 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(2);
assert_option_some_ne!(a, b);

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

§Module macros