From aea076944d91f1d5e0b99ecc2471e6722c73b665 Mon Sep 17 00:00:00 2001 From: Thomas Heslin <13917706+tjheslin1@users.noreply.github.com> Date: Fri, 3 Dec 2021 12:30:05 +0000 Subject: [PATCH] Implement `cargo clippy` lints --- 2021/day3/src/diagnostics.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/2021/day3/src/diagnostics.rs b/2021/day3/src/diagnostics.rs index ffbbb98..f8db0b2 100644 --- a/2021/day3/src/diagnostics.rs +++ b/2021/day3/src/diagnostics.rs @@ -46,7 +46,7 @@ fn find_by_bit_criteria(readings: &[&str], most_common: bool, on_match: char) -> if acc.len() > 1 { acc.iter() .filter(|line| line.chars().nth(index).unwrap() == bit_to_match) - .map(|x| *x) + .copied() .collect::>() } else { acc @@ -82,12 +82,10 @@ fn find_common_bit(most_common: bool, column: &str, on_match: char) -> char { } else { '1' } + } else if most_common { + '1' } else { - if most_common { - '1' - } else { - '0' - } + '0' } }