title: Can you provide any example where the closure outlives the current function?
body: <p>Based on the Rust book, the following code can cause the <code>closure may outlive the current function</code> error:</p>
  
  <pre><code>use std::thread;
  
  fn main() {
      let x = 1;
      thread::spawn(|| {
          println!("x is {}", x);
      });
  }
  </code></pre>
  
  <p>It is abstract to think when and how the closure would outlive the current function happen; can you provide any examples or specifications? </p>