From 452ab26aa735c85756ca0ec91453fe72d487af1b Mon Sep 17 00:00:00 2001 From: fointard Date: Tue, 19 Apr 2022 17:37:00 +0200 Subject: [PATCH] refactor(using_as): improve readability by using sum() instead of fold() --- exercises/conversions/using_as.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index 821309ec..f3f745ff 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::(); total / values.len() }