title: How to use use Pin rather than Arc to pass a Vec<u8> by reference to an async block?
body: <p>I want to do an operation on a <code>Vec&lt;u8&gt;</code> multiple times using an <code>Arc</code>:</p>
  
  <pre><code>use futures::{
      executor::{block_on, ThreadPool},
      task::SpawnExt,
  }; // 0.3.4
  use std::{pin::*, sync::Arc};
  
  fn foo(b: Arc&lt;Vec&lt;u8&gt;&gt;) {
      println!("{:?}", b);
  }
  
  #[test]
  fn pin_test() {
      let v = Arc::new(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
      let mut pool = ThreadPool::new().unwrap();
      for _ in 0..10 {
          let v1 = v.clone();
          let handle = pool
              .spawn_with_handle(async {
                  foo(v1);
              })
              .unwrap();
          block_on(handle);
      }
  }
  </code></pre>
  
  <p>I was expecting to be able to <code>Pin</code> the <code>Vec&lt;u8&gt;</code> instead</p>
  
  <pre><code>use futures::{
      executor::{block_on, ThreadPool},
      task::SpawnExt,
  }; // 0.3.4
  use std::{pin::*, sync::Arc};
  
  fn foo(b: &amp;[u8]) {
      println!("{:?}", b);
  }
  
  #[test]
  fn pin_test() {
      let v = Pin::new(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
      let mut pool = ThreadPool::new().unwrap();
      for _ in 0..10 {
          let v1 = v.clone();
          let handle = pool
              .spawn_with_handle(async {
                  foo(&amp;*v1);
              })
              .unwrap();
          block_on(handle);
      }
  }
  </code></pre>
  
  <p>This gives the error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0597]: `v1` does not live long enough
    --&gt; src/lib.rs:19:23
     |
  18 |                .spawn_with_handle(async {
     |   ________________________________-_____-
     |  |________________________________|
     | ||
  19 | ||                 foo(&amp;*v1);
     | ||                       ^^ borrowed value does not live long enough
  20 | ||             })
     | ||             -
     | ||_____________|
     | |______________value captured here by generator
     |                argument requires that `v1` is borrowed for `'static`
  ...
  23 |        }
     |        - `v1` dropped here while still borrowed
  </code></pre>
  
  <p>I understood that <code>Pin</code> should pin the <code>Vec</code> data to a specific point, such that all the calls could reference the same data. What is the right way to use <code>Pin</code> so that I can pass a reference to <code>foo()</code>?</p>
  
  <p>I'm using Rust 1.39.</p>