refactor(using_as): improve readability by using sum() instead of fold()

This commit is contained in:
fointard 2022-04-19 17:37:00 +02:00
parent 0b7f3fe37a
commit 452ab26aa7
No known key found for this signature in database
GPG Key ID: 7FC786FDA2727144
1 changed files with 1 additions and 1 deletions

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()
}