I have been trying this for my own project and I have to say it is very convenient. However I am noticing that functions with lots of calls that can fail are a bit awkward to write since the ?-operator does not work.
#[get("/foo")]
#[has_permissions("foo")]
pub async fn foo() -> Result<HttpResponse, SomeError> {
let a = thing_that_might_fail().await?; //<-- Error: ? can only be used in a function that returns Result or...
let b = other_thing(a).await?; //<-- Error
let c = yet_other_thing(b).await?; //<-- Error
Ok(and_so_on(c).await)
}
Do you have any suggestions for how I should write a similar function? Or might I request some way of supporting the ?-operator :)
It's a good point!
Indeed, at the moment there is a bug with Result when used in conjunction with a macro.
We should support this case in the actix-web-grants crate.
Hi!
I have been trying this for my own project and I have to say it is very convenient. However I am noticing that functions with lots of calls that can fail are a bit awkward to write since the ?-operator does not work.
Do you have any suggestions for how I should write a similar function? Or might I request some way of supporting the ?-operator :)