konst::result

Macro ok

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

A const equivalent of Result::ok

ยงExample

use konst::result;

// Necessary for type inference reasons.
type Res = Result<u32, u32>;

const ARR: &[Option<u32>] = &[
    result::ok!(Res::Ok(3)),
    result::ok!(Res::Err(8)),
];

assert_eq!(ARR, &[Some(3), None]);