Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Sum All

Use .iter().sum() to calculate the sum of vec![10, 20, 30, 40].

Expected output:

text
Total: 100

Hints:

  • let total: i32 = numbers.iter().sum();
  • You need the type annotation : i32 so Rust knows what type to sum into
rust
fn main() {
}