konst::option

Macro ok_or

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

A const equivalent of Option::ok_or

ยงExample

use konst::option;

const ARR: &[Result<u32, u32>] = &[
    option::ok_or!(Some(3), 10000),
    option::ok_or!(None, 5),
];

assert_eq!(ARR, &[Ok(3), Err(5)]);