title: How to take, transform and replace a vector in a mutable reference?
body: <p>I have a <code>struct Database { events: Vec&lt;Event&gt; }</code>. I would like to apply some maps and filters to <code>events</code>. What is a good way to do this?</p>
  <p>Here's what I tried:</p>
  <pre class="lang-rust prettyprint-override"><code>fn update(db: &amp;mut Database) {
      db.events = db.events.into_iter().filter(|e| !e.cancelled).collect();
  }
  </code></pre>
  <p>This doesn't work:</p>
  <pre class="lang-none prettyprint-override"><code>cannot move out of `db.events` which is behind a mutable reference
  ...
  move occurs because `db.events` has type `Vec&lt;Event&gt;`, which does not implement the `Copy` trait
  </code></pre>
  <p>Is there any way to persuade Rust compiler that I'm taking the field value only temporarily?</p>