Macro abi_stable::rtry_opt

source ·
macro_rules! rtry_opt {
    ($expr:expr) => { ... };
}
Expand description

Equivalent to ? for ROption.

Accepts both Option and ROption arguments.

§Example

use abi_stable::{
    std_types::{ROption, RSome, RNone},
    rtry_opt,
    sabi_extern_fn,
};


#[sabi_extern_fn]
fn funct(arg: ROption<u32>) -> ROption<u32> {
    let value = rtry_opt!(Some(3));
    RSome(value + rtry_opt!(arg))
}

assert_eq!(funct(RSome(5)), RSome(8));
assert_eq!(funct(RNone), RNone::<u32>);