I'm trying to find the dot product of two vectors:
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) => x * y).sum();
println!("{}", r);
}
This fails with
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `=>`
--> src/main.rs:4:58
|
4 | let r = a.iter().zip(b.iter()).map(|x, y| Some(x, y) => x * y).sum();
| ^^ expected one of `)`, `,`, `.`, `?`, or an operator here
I've also tried these, all of which failed:
let r = a.iter().zip(b.iter()).map(|x, y| => x * y).sum();
let r = a.iter().zip(b.iter()).map(Some(x, y) => x * y).sum();
What is the correct way of doing this?