title: How can I specify a lifetime for closure arguments?
body: <p>Playpen link: <a href="http://is.gd/EpX6lM" rel="nofollow">http://is.gd/EpX6lM</a></p>
  
  <p>I have a closure that takes a slice and returns a subslice of it. Compiling the following code on rust-1.0.0-beta-2 fails:</p>
  
  <pre class="lang-rust prettyprint-override"><code>trait OptionalFirst {
      fn optional_first&lt;'a&gt;(&amp;self, x: &amp;'a [usize]) -&gt; &amp;'a [usize];
  }
  
  impl&lt;F&gt; OptionalFirst for F where F: Fn(&amp;[usize]) -&gt; &amp;[usize] {
      fn optional_first&lt;'a&gt;(&amp;self, x: &amp;'a [usize]) -&gt; &amp;'a [usize] {
          (*self)(x)
      }
  }
  
  fn main() {
      let bc: Box&lt;OptionalFirst&gt; = Box::new(
          |x: &amp;[usize]| -&gt; &amp;[usize] {
              if x.len() != 0 {
                  &amp;x[..1]
              }
              else {
                  &amp;x[..0]
              }
          }) as Box&lt;OptionalFirst&gt;;
  
      let a: [usize; 3] = [1, 2, 3];
      let b: &amp;[usize] = bc.optional_first(&amp;a);
      println!("{:?}", b);
  }
  </code></pre>
  
  <p>I know how to define a lifetime in a closure's type (using <code>for &lt;'a&gt;</code>), but I don't know how to specify it in the closure's implementation.</p>