// Option, and the type alias expansion that `Result` in base16ct needs. type MyResult = Result; fn first_even(a: i32, b: i32) -> Option { if a % 2 == 0 { Some(a) } else if b % 2 == 0 { Some(b) } else { None } } fn checked(n: i32) -> MyResult { let v: Option = first_even(n, n + 1); let got: i32 = v.ok_or(-1)?; Ok(got * 10) } fn main() { println!("{:?} {:?}", first_even(2, 3), first_even(1, 3)); println!("{}", first_even(1, 4).unwrap()); println!("{}", first_even(1, 3).unwrap_or(-7)); println!("{:?} {:?}", checked(2), checked(1)); }