2018: day05: fix clippy warnings

This commit is contained in:
Antoine Martin 2019-11-25 19:07:26 +01:00
parent a5caa00dbf
commit f743d60f85

View file

@ -11,12 +11,12 @@ pub fn run() -> Result<()> {
Ok(()) Ok(())
} }
fn same_type(a: &char, b: &char) -> bool { fn same_type(a: char, b: char) -> bool {
a.to_ascii_lowercase() == b.to_ascii_lowercase() a.to_ascii_lowercase() == b.to_ascii_lowercase()
} }
fn remove_type(input: &str, c: &char) -> String { fn remove_type(input: &str, c: char) -> String {
input.chars().filter(|ch| !same_type(c, ch)).collect() input.chars().filter(|ch| !same_type(c, *ch)).collect()
} }
fn collapse(input: &str) -> String { fn collapse(input: &str) -> String {
@ -29,7 +29,7 @@ fn collapse(input: &str) -> String {
match last { match last {
Some(elem) => { Some(elem) => {
// if same type but different polarity // if same type but different polarity
if same_type(&elem, &next) && elem != next { if same_type(elem, next) && elem != next {
// drop both elem and next // drop both elem and next
last = res.pop(); last = res.pop();
} else { } else {
@ -65,7 +65,7 @@ fn part2(input: &str) -> usize {
} }
set.iter() set.iter()
.map(|c| collapse(&remove_type(input, c)).len()) .map(|c| collapse(&remove_type(input, *c)).len())
.min() .min()
.unwrap() .unwrap()
} }