title: lifetimes do not match method in trait when get token from request
body: <p>I am learning Rust. Now I am using this code to get the <code>accessToken</code> from the HTTP request header in Rust rocket:</p>
  <pre><code>use rocket::request::FromRequest;
  use rocket::{Request, request};
  use rocket::outcome::Outcome;
  use rocket::http::Status;
  
  struct Token(String);
  
  #[derive(Debug)]
  enum ApiTokenError {
      Missing,
      Invalid,
  }
  
  impl&lt;'a, 'r&gt; FromRequest&lt;'a&gt; for Token {
      type Error = ApiTokenError;
  
      fn from_request(request: &amp;'a Request&lt;'r&gt;) -&gt; request::Outcome&lt;Self, Self::Error&gt; {
          let token = request.headers().get_one(&quot;token&quot;);
          match token {
              Some(token) =&gt; {
                  // check validity
                  Outcome::Success(Token(token.to_string()))
              }
              None =&gt; Outcome::Failure((Status::Unauthorized, ApiTokenError::Missing)),
          }
      }
  }
  </code></pre>
  <p>When I compile the project, it shows an error like this:</p>
  <pre><code>error[E0195]: lifetime parameters or bounds on method `from_request` do not match the trait declaration
    --&gt; src/token.rs:17:20
     |
  17 |     fn from_request(request: &amp;'a Request&lt;'r&gt;) -&gt; request::Outcome&lt;Self, Self::Error&gt; {
     |                    ^ lifetimes do not match method in trait
  </code></pre>
  <p>Where is the code going wrong and what should I do to fix this problem?</p>