fix(polls): apply clippy suggestions

This commit is contained in:
Ondřej Pešek 2023-04-08 10:41:12 +02:00
parent 94a781c82c
commit ec226e0cab

View file

@ -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::<Vec<Self>>())
}
}