use anyhow::{Context as _, Result, anyhow};
fn main() {
let closure = | x: i32 | -> anyhow::Result<()> {
if x > 5 {
return Err(anyhow!("bla"))
} else {
return Ok(())
}
};
let x = closure(9)?;
}
It won't compile, the error I get is "the ?
operator can only be used in a function that returns Result
or Option
(or another type that implements FromResidual
)", even tho the closure return type is Result!