title: What is the idiomatic way to transform vector of structs to another vector of structs
body: <p>My function takes a <code>Vec</code> of structs as a parameter and places each of it's element into another vector as a new structure field:</p>
  <pre><code>fn new(cards: Vec&lt;Card&lt;'t&gt;&gt;) -&gt; Self {
          CardsConnection {
              edges: cards.iter().map(|c| CardsConnectionEdge {
                  cursor: c.id.clone(),
                  node: *c
              }).collect::&lt;Vec&lt;CardsConnectionEdge&gt;&gt;()
          }
      }
  </code></pre>
  <p>I really want a move, so only new vector should own the <code>Card</code> instances. So since map got a reference, I want do dereference it to move the value, but I got the following error:</p>
  <pre><code>error[E0507]: cannot move out of `*c` which is behind a shared reference
    --&gt; src/model.rs:74:23
     |
  74 |                 node: *c
     |                       ^^ move occurs because `*c` has type `model::Card&lt;'_&gt;`, which does not implement the `Copy` trait
  
  error: aborting due to previous error; 8 warnings emitted
  </code></pre>
  <p>While this non &quot;functional-style&quot; code works fine:</p>
  <pre><code>fn new(cards: Vec&lt;Card&lt;'t&gt;&gt;) -&gt; Self {
          let mut edges = Vec::&lt;CardsConnectionEdge&gt;::with_capacity(cards.len());
  
          for c in cards {
              edges.push(CardsConnectionEdge {
                  cursor: c.id.clone()
                  node: c
              })
          }
  
          CardsConnection {
              edges
          }
      }
  </code></pre>
  <p>but looks a bit clumsy.</p>
  <p>It there a way to do the same thing using iterators or some kind of map function? Or what is the idiomatic way of solving this kind of problems?</p>