title: What does "cannot move out of index of" mean?
body: <p>I am playing with <a href="http://www.rust-lang.org/" rel="noreferrer">Rust</a>, and I'm trying to access the first command line argument with this code:</p>
  
  <pre><code>use std::env;
  
  fn main() {
      let args: Vec&lt;_&gt; = env::args().collect();
      let dir = args[1];
  }
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0507]: cannot move out of indexed content
   --&gt; src/main.rs:5:15
    |
  5 |     let dir = args[1];
    |         ---   ^^^^^^^ cannot move out of indexed content
    |         |
    |         hint: to prevent move, use `ref dir` or `ref mut dir`
  </code></pre>
  
  <p>Or in later versions of Rust:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0507]: cannot move out of index of `std::vec::Vec&lt;std::string::String&gt;`
   --&gt; src/main.rs:5:15
    |
  5 |     let dir = args[1];
    |               ^^^^^^^
    |               |
    |               move occurs because value has type `std::string::String`, which does not implement the `Copy` trait
    |               help: consider borrowing here: `&amp;args[1]`
  </code></pre>
  
  <p>If I change it to <code>let ref dir</code>, it compiles, but I don't grok what's going on. Could someone explain what "indexed content" means?</p>