title: thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2' crash
body: <pre class="lang-rust prettyprint-override"><code>use std::env;
  use std::process;
  
  fn main(){
      let mut repository_urls: Vec&lt;String&gt; = env::args().collect();
      if repository_urls.len() == 1 {
          eprintln!("You have to enter at least one repository url!");
          process::exit(1);
      } else {
          for i in 0 .. repository_urls.len() - 1 {
              if repository_urls[i + 1] == "--advanced" &amp;&amp; repository_urls.len() &gt;= i + 5 {
                  repository_urls.remove(i + 4);
                  repository_urls.remove(i + 3);
                  repository_urls.remove(i + 2);
              } else {
  
              }
          }
          //Ends the process normally
          process::exit(0);
      }
  }
  
  </code></pre>
  
  <p>If you were to have <code>--advanced 1 2 3</code> for the arguments for this it would do everything and execute all the logic as intended but when it finishes it ends up crashing with:</p>
  
  <pre><code>thread 'main' panicked at 'index out of bounds: the len is 2 but the index is 2', /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/libcore/slice/mod.rs:2695:10
  note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
  </code></pre>
  
  <p>How would I get my program but exit normally without a crash?</p>