macro_rules! assert_some {
    ($cond:expr,) => { ... };
    ($cond:expr) => { ... };
    ($cond:expr, $($arg:tt)+) => { ... };
}
Expand description

Asserts that expression returns Some(T) variant.

Uses

Assertions are always checked in both debug and release builds, and cannot be disabled. See debug_assert_some! 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 = Some(42);

assert_some!(maybe);

// With custom messages
assert_some!(maybe, "Found it at {:?}", maybe);

None variant will cause panic:

let maybe = None;

assert_some!(maybe);  // Will panic