mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-01-24 04:16:19 +02:00
refactor(using_as): improve readability by using sum() instead of fold()
This commit is contained in:
parent
0b7f3fe37a
commit
452ab26aa7
@ -8,7 +8,7 @@
|
|||||||
// I AM NOT DONE
|
// I AM NOT DONE
|
||||||
|
|
||||||
fn average(values: &[f64]) -> f64 {
|
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()
|
total / values.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user