Rocket, from_request and '?'

I saw that a Rocket example uses the ? after having tried to extract a state variable in a request guard:

fn from_request(req: &'a Request<'r>) -> request::Outcome<Account, MyError> {
  let state = req.guard::<State<SharedState>>()?;
  // ...

It is unclear to me what the From conversion should look like to get it to accept this code. The error is:

error[E0277]: `?` couldn't convert the error to `std::result::Result<(), (rocket::http::Status, err::Error)>`
   --> src/
165 |     let state = req.guard::<State<SharedState>>()?;
    |                                                  ^ the trait `std::convert::From<std::result::Result<(), (rocket::http::Status, ())>>` is not implemented for `std::result::Result<(), (rocket::http::Status, err::Error)>`
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = note: required by `std::convert::From::from`

Does anyone have a working example of handling ? and Rocket's Outcome?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.