darkwing

Macro unreachable_if_none

source
macro_rules! unreachable_if_none {
    ($value:expr) => { ... };
}
Expand description

Unwraps an Option, panicking with unreachable!() if the value is None.

This macro is intended for use in situations where the Option is guaranteed to contain a value based on prior logic, and a None value would indicate a programming error.

§Examples

let value: Option<i32> = Some(42);
let unwrapped = unreachable_if_none!(value);
assert_eq!(unwrapped, 42);

§Panics

Panics with unreachable!() if the Option is None.