title: When to use reference while iterating vectors in Rust?
body: <p>I'm confused as to when to use references. I have a vector  and I'd like to iterate through the elements inside it.</p>
  <pre><code>let v = vec![1, 2, 3, 4, 5];
  </code></pre>
  <p>I can do this using a <code>for</code> loop in two ways:</p>
  <h3>Method 1</h3>
  <pre><code>for element in &amp;v {
      println!(&quot;{}&quot;, element);
  }
  </code></pre>
  <h3>Method 2</h3>
  <pre><code>for element in v {
      println!(&quot;{}&quot;, element);
  }
  </code></pre>
  <p>In method 1, I use a reference to access the contents of the vector <code>v</code>. Both examples compile and give the desired output. Which method to use and why?</p>