From 92a5d0037f0124eb2cdd8637762ca6aa4494fcbd Mon Sep 17 00:00:00 2001 From: fointard Date: Tue, 19 Apr 2022 17:11:27 +0200 Subject: [PATCH 1/4] refactor(arc1): improve readability by using functional style --- exercises/standard_library_types/arc1.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/exercises/standard_library_types/arc1.rs b/exercises/standard_library_types/arc1.rs index d167380..f60061e 100644 --- a/exercises/standard_library_types/arc1.rs +++ b/exercises/standard_library_types/arc1.rs @@ -32,12 +32,7 @@ fn main() { for offset in 0..8 { let child_numbers = // TODO joinhandles.push(thread::spawn(move || { - let mut i = offset; - let mut sum = 0; - while i < child_numbers.len() { - sum += child_numbers[i]; - i += 8; - } + let sum: u32 = child_numbers.iter().filter(|n| *n % 8 == offset).sum(); println!("Sum of offset {} is {}", offset, sum); })); } From 452ab26aa735c85756ca0ec91453fe72d487af1b Mon Sep 17 00:00:00 2001 From: fointard Date: Tue, 19 Apr 2022 17:37:00 +0200 Subject: [PATCH 2/4] 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 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::(); total / values.len() } From 107f1f97d96cb79513a7ff62d92e52c4296a69e8 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 07:14:26 +0000 Subject: [PATCH 3/4] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 1dc5647..9b388bb 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -164,6 +164,7 @@ authors.
ragreenburg

🖋
stevenfukase

🖋
J-S-Kim

🖋 +
Fointard

🖋 From c9b73e412ed49f05c999a3ecf640209d5700dfac Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 07:14:27 +0000 Subject: [PATCH 4/4] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 26fd5c9..d3f0c2c 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1146,6 +1146,15 @@ "contributions": [ "content" ] + }, + { + "login": "Fointard", + "name": "Fointard", + "avatar_url": "https://avatars.githubusercontent.com/u/9333398?v=4", + "profile": "https://github.com/Fointard", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8,