title: How to call count on an iterator and still use the iterator's items?
body: <p><code>parts.count()</code> leads to ownership transfer, so <code>parts</code> can't be used any more.</p>
  
  <pre><code>fn split(slice: &amp;[u8], splitter: &amp;[u8]) -&gt; Option&lt;Vec&lt;u8&gt;&gt; {
      let mut parts = slice.split(|b| splitter.contains(b));
  
      let len = parts.count(); //ownership transfer
  
      if len &gt;= 2 {
          Some(parts.nth(1).unwrap().to_vec())
      } else if len &gt;= 1 {
          Some(parts.nth(0).unwrap().to_vec())
      } else {
          None
      }
  }
  
  fn main() {
      split(&amp;[1u8, 2u8, 3u8], &amp;[2u8]);
  }
  </code></pre>