title: Is there a built-in way to compare two iterators?
body: <p>I've written the following function to compare two iterators, element-by-element. However, it would be great if I could just reuse something in the standard library.</p>
  
  <pre><code>fn iter_eq&lt;A, B, T, U&gt;(mut a: A, mut b: B) -&gt; bool
  where
      A: Iterator&lt;Item = T&gt;,
      B: Iterator&lt;Item = U&gt;,
      T: PartialEq&lt;U&gt;,
  {
      loop {
          match (a.next(), b.next()) {
              (Some(ref a), Some(ref b)) if a == b =&gt; continue,
              (None, None) =&gt; return true,
              _ =&gt; return false,
          }
      }
  }
  
  fn main() {
      let a = vec![1, 2, 3].into_iter();
      let b = vec![1, 2, 3].into_iter();
  
      assert!(iter_eq(a, b));
  }
  </code></pre>