title: Value does not live long enough when using the Chunks iterator across multiple threads
body: <p>This is a simplified example of my situation:</p>
  
  <pre><code>use std::sync::mpsc::{Sender, Receiver};
  use std::sync::mpsc;
  use std::thread;
  
  struct User {
      reference: String,
      email: String,
  }
  
  fn main() {
      let rows = vec![
          vec!["abcd", "test@test.com"],
          vec!["efgh", "test1@test.com"],
          vec!["wfee", "test2@test.com"],
          vec!["rrgr", "test3@test.com"],
      ];
  
      let chunk_len = (rows.len() / 2) as usize;
      let mut chunks = Vec::new();
      for chunk in rows.chunks(chunk_len) {
          chunks.push(chunk);
      }
  
      let (tx, rx): (Sender&lt;Vec&lt;User&gt;&gt;, Receiver&lt;Vec&lt;User&gt;&gt;) = mpsc::channel();
  
      for chunk in chunks {
          let thread_tx = tx.clone();
          thread::spawn(move || {
              let result = chunk
                  .iter()
                  .map(|row| {
                      User {
                          reference: row[0].to_string(),
                          email: row[1].to_string(),
                      }
                  })
                  .collect::&lt;Vec&lt;User&gt;&gt;();
              thread_tx.send(result).unwrap();
          });
      }
  
      let mut users = Vec::new();
      for _ in 0..chunk_len {
          users.push(rx.recv());
      }
  }
  </code></pre>
  
  <p>and it's throwing an error</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0597]: `rows` does not live long enough
    --&gt; src/main.rs:20:18
     |
  20 |     for chunk in rows.chunks(chunk_len) {
     |                  ^^^^ does not live long enough
  ...
  47 | }
     | - borrowed value only lives until here
     |
     = note: borrowed value must be valid for the static lifetime...
  </code></pre>
  
  <p>I tried to change to <code>chunks.push(chunk.clone());</code> but the error still wouldn't go away. What am I missing here?</p>