Macro assertables::assert_option_some

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

Assert expression.is_some() is true.

  • 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);
assert_option_some!(a);

let a: Option<i8> = Option::None;
assert_option_some!(a);
// assertion failed: `assert_option_some!(option)`
//      option label: `a`,
//      option debug: `None`,
//  expr.is_some(): `false`

§Module macros