From ec226e0cabf5df520f98b50d2a51e85b249b0ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Pe=C5=A1ek?= Date: Sat, 8 Apr 2023 10:41:12 +0200 Subject: [PATCH] fix(polls): apply clippy suggestions --- src/utils.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index ad7b913..a8dbb61 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -119,7 +119,7 @@ impl Poll { } pub fn most_votes(&self) -> u64 { - self.poll_options.iter().map(|o| o.vote_count).flatten().max().unwrap_or(0) + self.poll_options.iter().filter_map(|o| o.vote_count).max().unwrap_or(0) } } @@ -134,7 +134,7 @@ impl PollOption { Some(options .as_array()? .iter() - .map(|option| { + .filter_map(|option| { // For each poll option // we can't just use as_u64() because "id": String("...") and serde would parse it as None @@ -149,7 +149,6 @@ impl PollOption { vote_count }) }) - .flatten() .collect::>()) } }