title: How to pass a PrimInt to multiple threads?
body: <p>I would like to write a function that accepts an integer, and spawns threads that use this integer. The integer could be computed. It doesn't need to be a literal. If I use a concrete type such as <code>usize</code>, it would work but when I try to generalize it, it <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=3a68effae1553bf3bfc0dc5ae0030a90" rel="nofollow noreferrer">fails to compile</a>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>fn g&lt;A&gt;(a: A)
  where
      A: num::PrimInt + Copy + std::fmt::Debug + Send,
  {
      let hs = (0..3).map(|_| {
          std::thread::spawn(move || {
              println!("{:?}", a);
          })
      });
  
      for h in hs {
          h.join().unwrap();
      }
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>1 | fn g&lt;A&gt;(a: A)
    |      - help: consider adding an explicit lifetime bound `A: 'static`...
  ...
  6 |         std::thread::spawn(move || {
    |         ^^^^^^^^^^^^^^^^^^
    |
  note: ...so that the type `[closure@src/main.rs:6:28: 8:10 a:A]` will meet its required lifetime bounds
   --&gt; src/main.rs:6:9
    |
  6 |         std::thread::spawn(move || {
    |         ^^^^^^^^^^^^^^^^^^
  </code></pre>
  
  <p>Since I have the <code>Copy</code> trait, it should be able to copy this value for each thread and hence the lifetime bound recommendation is not necessary. How do I resolve this?</p>