1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-06-23 00:28:46 +02:00

Merge pull request #969 from Fointard/fointard_using_as

refactor(using_as): improve readability by using sum() instead of fold()
This commit is contained in:
diannasoreil
2022-04-20 09:15:22 +02:00
committed by GitHub

View File

@ -8,7 +8,7 @@
// I AM NOT DONE
fn average(values: &[f64]) -> f64 {
let total = values.iter().fold(0.0, |a, b| a + b);
let total = values.iter().sum::<f64>();
total / values.len()
}