darkwing

Macro unreachable_if_none_ref

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

Similar to unreachable_if_none!, but clones the Option and its contents before unwrapping.

This macro is useful when working with references inside Options that need to be cloned.

§Examples

let value: Option<String> = Some("hello".to_string());
let cloned = unreachable_if_none_ref!(value);
assert_eq!(cloned, "hello");

§Panics

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