title: How do I compute the dot product of two Rust arrays / slices / vectors?
body: <p>I'm trying to find the dot product of two vectors:</p>
  
  <pre><code>fn main() {
      let a = vec![1, 2, 3, 4];
      let b = a.clone();
      let r = a.iter().zip(b.iter()).map(|x, y| Some(x, y) =&gt; x * y).sum();
      println!("{}", r);
  }
  </code></pre>
  
  <p>This fails with</p>
  
  <pre class="lang-none prettyprint-override"><code>error: expected one of `)`, `,`, `.`, `?`, or an operator, found `=&gt;`
   --&gt; src/main.rs:4:58
    |
  4 |     let r = a.iter().zip(b.iter()).map(|x, y| Some(x, y) =&gt; x * y).sum();
    |                                                          ^^ expected one of `)`, `,`, `.`, `?`, or an operator here
  </code></pre>
  
  <p>I've also tried these, all of which failed:</p>
  
  <pre><code>let r = a.iter().zip(b.iter()).map(|x, y| =&gt; x * y).sum();
  let r = a.iter().zip(b.iter()).map(Some(x, y) =&gt; x * y).sum();
  </code></pre>
  
  <p>What is the correct way of doing this?</p>
  
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e650008c52d67f105acd2a898bf154c9" rel="noreferrer">(Playground)</a></p>