Macro konst::result::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]);