title: Implement Iterator in Rust
body: <p>I'm making an iterator in rust. In the <code>next()</code> method I want to extract <code>next_element</code> as <code>current_element</code> which will be returned, and create new <code>Term</code> instance and set it as <code>next_element</code>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>pub struct Term {
      pub coefficient: f64,
      pub index: i32,
      pub exponent: f64,
  }
  
  pub struct SeriesIterator {
      next_element: Term,
  }
  
  impl Iterator for SeriesIterator {
      type Item = Term;
      fn next(&amp;mut self) -&gt; Option&lt;Self::Item&gt; {
          let current_element = self.next_element;
          self.next_element = Term {
              coefficient: 1.0,
              index: current_element.index + 1,
              exponent: f64::from(current_element.index + 1),
          };
          Some(current_element)
      }
  }
  </code></pre>
  
  <p>How to move ownership of <code>next_element</code> into <code>current_element</code> which will finally be moved outside with the return of <code>next()</code>?</p>
  
  <pre><code>cannot move out of `self.next_element` which is behind a mutable reference
     |
     |     let current_element = self.next_element;
     |                          ^^^^^^^^^^^^^^^^
  </code></pre>