'Rust: modify values in Vec with other values in Vec
Given this code:
let sides = vec![2, 3, 8];
let area = sides
.iter()
.map(|x| x) // how can i access other members of sides here?
.sum::<u32>();
println!("area: {}", area);
Assuming sides is filled with values representing width, height, and length, how can I modify the .map() line to length * width, width * height, and height * length?
Playground available here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
