title: Rust function return type with lifetime value
body: <p>I'd like to implement the <code>Responder</code> trait for my <code>Hero</code> structure, but the following method signature (<code>respond_to</code>):</p>
  
  <pre class="lang-rust prettyprint-override"><code>use rocket::{http::Status, response::Responder, Request, Response};
  use serde::{Deserialize, Serialize};
  
  #[derive(Serialize, Deserialize)]
  pub struct Hero {
      pub id: Option&lt;i32&gt;,
      pub name: String,
      pub identity: String,
      pub hometown: String,
      pub age: i32,
  }
  
  impl Hero {
      pub fn new(
          num: Option&lt;i32&gt;,
          name: String,
          identity: String,
          hometown: String,
          age: i32,
      ) -&gt; Hero {
          Hero {
              id: num,
              name,
              identity,
              hometown,
              age,
          }
      }
  }
  
  impl&lt;'r&gt; Responder&lt;'r&gt; for Hero {
      fn respond_to(self, _request: &amp;Request) -&gt; Result&lt;Response, Status&gt; {
          unimplemented!()
      }
  }
  </code></pre>
  
  <p>Throws a compilation error:</p>
  
  <pre><code>error[E0106]: missing lifetime specifier
    --&gt; src/main.rs:32:55
     |
  32 |     fn respond_to(self, _request: &amp;Request) -&gt; Result&lt;Response, Status&gt; {
     |                                                       ^^^^^^^^ expected lifetime parameter
     |
     = help: this function's return type contains a borrowed value, but the signature does not say which one of `_request`'s 2 lifetimes it is borrowed from
  </code></pre>
  
  <p>Dependencies:</p>
  
  <pre><code>[dependencies]
  rocket = "0.4.2"
  serde = {version = "1.0.99", features=["derive"]}
  </code></pre>
  
  <p>The documentation doesn't provide an example of how to provide lifetimes when a type is returned. How to specify lifetime when a type is returned?</p>