title: Why does the argument for the find closure need two ampersands?
body: <p>I have been playing with Rust by <a href="https://github.com/ttsiodras/Score4/tree/master/Rust" rel="noreferrer">porting my Score4 AI engine</a> to it - basing the work on my functional-style implementation in OCaml. I specifically wanted to see how Rust fares with functional-style code.</p>
  
  <p>The end result: It works, and it's very fast - much faster than OCaml. It almost touches the speed of imperative-style C/C++ - which is really cool.</p>
  
  <p>There's a thing that troubles me, though — why do I need two ampersands in the last line of this code?</p>
  
  <pre><code>let moves_and_scores: Vec&lt;_&gt; = moves_and_boards
      .iter()
      .map(|&amp;(column,board)| (column, score_board(&amp;board)))
      .collect();
  let target_score = if maximize_or_minimize { 
      ORANGE_WINS 
  } else { 
      YELLOW_WINS 
  };
  if let Some(killer_move) = moves_and_scores.iter()
      .find(|&amp; &amp;(_,score)| score==target_score) {
           ...
  </code></pre>
  
  <p>I added them is because the compiler errors "guided" me to it; but I am trying to understand why... I used the trick mentioned elsewhere in Stack Overflow to "ask" the compiler to tell me what type something is:</p>
  
  <pre><code>let moves_and_scores: Vec&lt;_&gt; = moves_and_boards
      .iter()
      .map(|&amp;(column,board)| (column, score_board(&amp;board)))
      .collect();
  let () = moves_and_scores;
  </code></pre>
  
  <p>...which caused this error:</p>
  
  <pre><code>src/main.rs:108:9: 108:11 error: mismatched types:
   expected `collections::vec::Vec&lt;(u32, i32)&gt;`,
      found `()`
  (expected struct `collections::vec::Vec`,
      found ()) [E0308]
  src/main.rs:108     let () = moves_and_scores;
  </code></pre>
  
  <p>...as I expected, <code>moves_and_scores</code> is a vector of tuples: <code>Vec&lt;(u32, i32)&gt;</code>. But then, in the immediate next line, <code>iter()</code> and <code>find()</code> force me to use the hideous double ampersands in the closure parameter:</p>
  
  <pre><code>if let Some(killer_move) = moves_and_scores.iter()
      .find(|&amp; &amp;(_,score)| score==target_score) {
  </code></pre>
  
  <p>Why does the <code>find</code> closure need two ampersands? I could see why it may need one (pass the tuple by reference to save time/space) but why two? Is it because of the <code>iter</code>?  That is, is the <code>iter</code> creating references, and then <code>find</code> expects a reference on each input, so a reference on a reference?</p>
  
  <p>If this is so, isn't this, arguably, a rather ugly design flaw in Rust? </p>
  
  <p>In fact, I would expect <code>find</code> and <code>map</code> and all the rest of the functional primitives to be parts of the collections themselves. Forcing me to <code>iter()</code> to do any kind of functional-style work seems burdensome, and even more so if it forces this kind of "double ampersands" in every possible functional chain.</p>
  
  <p>I am hoping I am missing something obvious - any help/clarification most welcome.</p>