Macro konst::result::unwrap_or

source ·
macro_rules! unwrap_or {
    ($res:expr, $v:expr $(,)?) => { ... };
}
Expand description

A const equivalent of Result::unwrap_or

§Example

use konst::result;

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

const ARR: &[u32] = &[
    result::unwrap_or!(Res::Ok(3), 5),
    result::unwrap_or!(Res::Err(8), 13),
];

assert_eq!(ARR, &[3, 13]);