diff options
| author | diannasoreil <mokou@fastmail.com> | 2022-04-20 09:15:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-20 09:15:22 +0200 |
| commit | 1237aa574ca45b09893ba2d1ed85a4e2ff76600b (patch) | |
| tree | e0be0392163403689c1e2b64082cda823fe0a966 | |
| parent | b3734ba3108c0c847c51f8484982e1d28a02cf77 (diff) | |
| parent | 452ab26aa735c85756ca0ec91453fe72d487af1b (diff) | |
Merge pull request #969 from Fointard/fointard_using_as
refactor(using_as): improve readability by using sum() instead of fold()
| -rw-r--r-- | exercises/conversions/using_as.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index 821309e..f3f745f 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -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() } |
