title: Why do the vector values not get move to the Ordering function in the below code?
body: <p>I am a Rust noob and I have been going through a few videos and articles. I was following this article <a href="https://hermanradtke.com/2015/06/22/effectively-using-iterators-in-rust.html/#:%7E:text=The%20.into_iter%20%28%29%20function%20creates%20a%20IntoIter%3CT%3E%20type,the%20words%20owned%20or%20consumed%20interchangeably%20with%20moved." rel="nofollow noreferrer">here</a> about Rust iterators.</p>
  <p>When it is explaining <code>iter_mut()</code> it uses the following example.</p>
  <pre><code>fn main() {
      let mut teams = [
          [ (&quot;Jack&quot;, 20), (&quot;Jane&quot;, 23), (&quot;Jill&quot;, 18), (&quot;John&quot;, 19), ],
          [ (&quot;Bill&quot;, 17), (&quot;Brenda&quot;, 16), (&quot;Brad&quot;, 18), (&quot;Barbara&quot;, 17), ]
      ];
  
      let teams_in_score_order = teams
          .iter_mut()
          .map(|team| {
              team.sort_by(|&amp;a, &amp;b| a.1.cmp(&amp;b.1).reverse());
              team
          })
          .collect::&lt;Vec&lt;_&gt;&gt;();
      
      println!(&quot;Teams: {:?}&quot;, teams_in_score_order);
  }
  </code></pre>
  <p>Here <code>team.sort_by(|&amp;a, &amp;b| a.1.cmp(&amp;b.1).reverse())</code> VS Code tells me that these are the variable types.</p>
  <pre><code>   a: (&amp;str, i32)
     b: (&amp;str, i32)
  </code></pre>
  <p>So here in the closure <code>a.1.cmp(&amp;b.1).reverse()</code>, <code>a</code> is not a borrowed value (according to my current understanding). So why wouldn't it get dropped at the end of the closure? I am assuming, that if <code>a</code> gets dropped, then there would not be any items left in the vector at the end of this function. One more question: Once a value is passed as a borrowed value, what does it mean to access without the <code>&amp;</code>?</p>
  <p>Also, I was trying to understand, defining closure parameters using <code>&amp;</code>. I understand <code>&amp;</code> means to reference/borrow a value. However here, I removed <code>&amp;</code> from <code>|&amp;a, &amp;b|</code> and it still worked, but at that point, types were defined as
  <code>a: &amp;(&amp;str, i32)</code>
  <code>b: &amp;(&amp;str, i32)</code>. Here what does it mean by having or not having <code>&amp;</code> in the parameter definition in <code>|&amp;a, &amp;b|</code>?</p>
  <p>Thanks in advance!</p>