Macro assertables::assert_some

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

Assert expression is Some(_).

Pseudocode:
a is Some(_)

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

let a: Option<i8> = Option::None;
assert_some!(a);
// assertion failed: `assert_some!(a)`
// https://docs.rs/assertables/8.7.0/assertables/macro.assert_some.html
//  option label: `a`,
//  option debug: `None`

§Module macros