title: What are the main differences between a Rust Iterator and C++ Iterator?
body: <p>A typical example of a C++ iterator is a pointer, and can be used to point at an element in a C array like so:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int array[] = {1, 2, 3, 4};
  int* begin = std::begin(array); //Starting iterator
  int* end = std::end(array) //Ending iterator
  
  for(int* i = begin; i &lt; end; i++)
  {
      std::cout &lt;&lt; *i &lt;&lt; ',';
  }
  
  //Prints 1, 2, 3, 4
  </code></pre>
  
  <p>This is simple enough. The definition of an iterator from <a href="http://www.cplusplus.com/reference/iterator/" rel="noreferrer">cplusplus.com</a> is </p>
  
  <blockquote>
    <p>An iterator is any object that, pointing to some element in a range of elements (such as an array or a container), has the ability to iterate through the elements of that range using a set of operators...</p>
  </blockquote>
  
  <p>This makes sense; in the above code there were two iterators (the <code>begin</code> and the <code>end</code> iterators), and it used a <code>for</code> loop and incremented.</p>
  
  <p>In Rust, an iterator is used like this:</p>
  
  <pre class="lang-rust prettyprint-override"><code>let vect = vec![1, 2, 3, 4];
  
  let vect_iter = vect.iter();
  </code></pre>
  
  <p>What? To iterate it you do:</p>
  
  <pre class="lang-rust prettyprint-override"><code>vect_iter.next();
  vect_iter.next();
  </code></pre>
  
  <p>I couldn't find any exact definition of a pointer in the Rust docs, but looking at the <a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html" rel="noreferrer"><code>Iterator</code> trait</a>, it is seems that an iterator is a wrapper for a container that enables for easier processing, by standardizing the logic in a way (if that makes sense at all).</p>
  
  <p>The main questions I have are:</p>
  
  <ol>
  <li>What are the main differences?</li>
  <li>Why does Rust have iterators in this fashion and why are they expressed so differently?</li>
  <li>Are there Rust-type iterators in C++?</li>
  <li>Are there C++-type iterators in Rust?</li>
  <li>Are they called something specific? (Internal/External?)</li>
  </ol>