Macro claim::assert_none
source · [−]macro_rules! assert_none {
($cond:expr,) => { ... };
($cond:expr) => { ... };
($cond:expr, $($arg:tt)+) => { ... };
}
Expand description
Asserts that expression returns None
variant.
Uses
Assertions are always checked in both debug and release builds, and cannot be disabled.
See debug_assert_none!
for assertions that are not enabled in release builds by default.
Custom messages
This macro has a second form, where a custom panic message can be provided
with or without arguments for formatting. See std::fmt
for syntax for this form.
Examples
let maybe: Option<i32> = None;
assert_none!(maybe);
// With custom messages
assert_none!(maybe, "Yep, there is nothing in here");
assert_none!(maybe, "we asserting that there are no droids we are looking for at {:?}", maybe);
Some(T)
variant will cause panic:
ⓘ
let maybe = Some(42i32);
assert_none!(maybe); // Will panic