title: Why are these two code samples equal? Difference between references, borrowed variables, pointers
body: <pre><code>fn largest(num_list: &amp;[i32]) -&gt; i32 {
      let mut largest = num_list[0];
  
      for &amp;num in num_list {
          if num &gt; largest {
              largest = num
          }
      }
  
      largest
  }
  
  fn largest2(num_list: &amp;[i32]) -&gt; i32 {
      let mut largest = num_list[0];
  
      for num in num_list {
          if num &gt; &amp;largest {
              largest = *num
          }
      }
  
      largest
  }
  
  fn main() {
      let num_list = vec![30, 20, 10, 60, 50, 40];
  
      let largest = largest(&amp;num_list);
      let largest2 = largest2(&amp;num_list);
  
      println!(&quot;The largest number in num_list fn is: {}.&quot;, largest);
      println!(&quot;The largest number in num_list fn is: {}.&quot;, largest2);
  }
  
  </code></pre>
  <p>As you can see there are some slight differences in <em><strong>largest</strong></em> and <em><strong>largest2</strong></em>. Can someone help me understand the differences here and why both samples of code actually function the same?</p>