Fold Product
Use .fold() to calculate the product of all numbers in vec![2, 3, 4]. Start with 1 as the initial value.
Expected output:
text
Product: 24
Hints:
.fold(1, |acc, x| acc * x)starts with 1 and multiplies each itemaccis the accumulator (running total),xis the current item
rust
fn main() {
}