konst::option

Macro unwrap

Source
macro_rules! unwrap {
    ($e:expr $(,)?) => { ... };
}
Expand description

A const equivalent of Option::unwrap

§Const stabilization

The equivalent std function was const-stabilized in Rust 1.83.0.

§Example

use konst::option::unwrap;

use std::num::NonZeroUsize;

const TEN: NonZeroUsize = unwrap!(NonZeroUsize::new(10));

assert_eq!(TEN.get(), 10);