assertables

Macro assert_option_some

source
macro_rules! assert_option_some {
    ($a:expr $(,)?) => { ... };
    ($a:expr, $($message:tt)+) => { ... };
}
👎Deprecated: Please rename from assert_option_some to assert_some because more developers prefer the shorter name.
Expand description

Assert expression 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_option_some!(a);

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

§Module macros