title: How to idiomatically iterate one half of an array and modify the structure of the other?
body: <p>What is the idiomatic way to iterate (read) over the first half of the vector and change the structure of the second half of the vector depending on the first? This is very abstract but some algorithms could be boiled down to this problem. I want to write this simplified C++ example in Rust:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>for (var i = 0; i &lt; vec.length; i++) {
      for (var j = i + 1 ; j &lt; vec.length; j++) {
          if (f(vec[i], vec[j])) {
              vec.splice(j, 1);
              j--;
          }
      }
  }
  </code></pre>