title: Returning a closure from a function
body: <p><strong>Note</strong>: This question was asked before Rust's first stable release. There have been lots of changes since and the syntax used in the function is not even valid anymore. Still, Shepmaster's answer is excellent and makes this question worth keeping.</p>
  
  <hr>
  
  <p>Finally unboxed closures have landed, so I am experimenting with them to see what you can do.</p>
  
  <p>I have this simple function:</p>
  
  <pre><code>fn make_adder(a: int, b: int) -&gt; || -&gt; int {
      || a + b
  }
  </code></pre>
  
  <p>However, I get a <code>missing lifetime specifier [E0106]</code> error. I have tried to fix this by changing the return type to <code>||: 'static -&gt; int</code>, but then I get another error <code>cannot infer an appropriate lifetime due to conflicting requirements</code>.</p>
  
  <p>If I understand correctly, the closure is unboxed so it owns <code>a</code> and <code>b</code>. It seems very strange to me that it needs a lifetime. How can I fix this?</p>