title: What is the idiomatic way of converting a Vec of references to a Vec of values?
body: <p>My function returns a <code>Vec</code> of references to a tuple, but I need a <code>Vec</code> of tuples:</p>
  
  <pre><code>use std::collections::HashSet;
  
  fn main() {
      let maxs: HashSet&lt;(usize, usize)&gt; = HashSet::new();
      let mins: HashSet&lt;(usize, usize)&gt; = HashSet::new();
      let intersection = maxs.intersection(&amp;mins).collect::&lt;Vec&lt;&amp;(usize, usize)&gt;&gt;();
  }
  </code></pre>
  
  <p>How should I do the conversion?</p>
  
  <p>Error:</p>
  
  <pre class="lang-none prettyprint-override"><code>19 |     maxs.intersection(&amp;mins).collect::&lt;Vec&lt;&amp;(usize, usize)&gt;&gt;()
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
     |
     = note: expected type `std::vec::Vec&lt;(usize, usize)&gt;`
            found type `std::vec::Vec&lt;&amp;(usize, usize)&gt;`
  </code></pre>
  
  <p>I'm <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2015&amp;gist=f2858443a65735412c0c1c7bf99cab39" rel="noreferrer">using a <code>for</code> loop to do the conversion</a>, but I don't like it and I think there should be a mode idiomatic way:</p>
  
  <pre><code>for t in maxs.intersection(&amp;mins).collect::&lt;Vec&lt;&amp;(usize, usize)&gt;&gt;().iter() {
      output.push(**t);
  }
  </code></pre>