clippy: fix lints
This commit is contained in:
parent
e01307eb3c
commit
e82df94852
|
@ -41,10 +41,10 @@ fn part1(input: &str) -> usize {
|
|||
|
||||
false
|
||||
})
|
||||
.filter(|line| line.find("ab").is_none())
|
||||
.filter(|line| line.find("cd").is_none())
|
||||
.filter(|line| line.find("pq").is_none())
|
||||
.filter(|line| line.find("xy").is_none())
|
||||
.filter(|line| !line.contains("ab"))
|
||||
.filter(|line| !line.contains("cd"))
|
||||
.filter(|line| !line.contains("pq"))
|
||||
.filter(|line| !line.contains("xy"))
|
||||
.count()
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ fn part2(input: &str) -> usize {
|
|||
for i in 0..(line.chars().count() - 3) {
|
||||
let seq = &line[i..(i + 2)];
|
||||
let line = &line[(i + 2)..];
|
||||
if line.find(seq).is_some() {
|
||||
if line.contains(seq) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ impl FromStr for Event {
|
|||
type Err = anyhow::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
if s.find("wakes up").is_some() {
|
||||
if s.contains("wakes up") {
|
||||
Ok(Event::WakeUp)
|
||||
} else if s.find("falls asleep").is_some() {
|
||||
} else if s.contains("falls asleep") {
|
||||
Ok(Event::FallAsleep)
|
||||
} else if s.find("begins shift").is_some() {
|
||||
} else if s.contains("begins shift") {
|
||||
let pound = s.find('#').context("`#` not found")?;
|
||||
let s = &s[(pound + 1)..];
|
||||
let space = s.find(' ').context("` ` not found after `#`")?;
|
||||
|
|
|
@ -48,7 +48,7 @@ fn part2(first_wire: &Wire, second_wire: &Wire) -> Result<u64> {
|
|||
let mut second_length = 0;
|
||||
|
||||
for seg2 in &second_wire.0 {
|
||||
if let Some(inter) = seg1.intersection(&seg2) {
|
||||
if let Some(inter) = seg1.intersection(seg2) {
|
||||
if inter.x == 0 && inter.y == 0 {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ fn part1(input: &str) -> Result<u64> {
|
|||
let mut cache = HashMap::new();
|
||||
Ok(orbits
|
||||
.keys()
|
||||
.map(|k| count_orbits(&k, &orbits, &mut cache))
|
||||
.map(|k| count_orbits(k, &orbits, &mut cache))
|
||||
.sum())
|
||||
}
|
||||
|
||||
|
|
|
@ -154,16 +154,16 @@ impl CompletePassport {
|
|||
|
||||
fn hgt_valid(&self) -> bool {
|
||||
if let Some(num) = self.hgt.strip_suffix("in") {
|
||||
is_number_in_range(&num, 59..=76)
|
||||
is_number_in_range(num, 59..=76)
|
||||
} else if let Some(num) = self.hgt.strip_suffix("cm") {
|
||||
is_number_in_range(&num, 150..=193)
|
||||
is_number_in_range(num, 150..=193)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn hcl_valid(&self) -> bool {
|
||||
if let Some(rest) = self.hcl.strip_prefix("#") {
|
||||
if let Some(rest) = self.hcl.strip_prefix('#') {
|
||||
rest.chars().filter(|c| !c.is_ascii_hexdigit()).count() == 0
|
||||
} else {
|
||||
false
|
||||
|
|
|
@ -64,13 +64,13 @@ impl Layout {
|
|||
|
||||
match cell {
|
||||
Cell::EmptySeat => {
|
||||
if adj_count(&self, i, j, Cell::OccupiedSeat) == 0 {
|
||||
if adj_count(self, i, j, Cell::OccupiedSeat) == 0 {
|
||||
new[i][j] = Cell::OccupiedSeat;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
Cell::OccupiedSeat => {
|
||||
if adj_count(&self, i, j, Cell::OccupiedSeat) >= occupied_threshold {
|
||||
if adj_count(self, i, j, Cell::OccupiedSeat) >= occupied_threshold {
|
||||
new[i][j] = Cell::EmptySeat;
|
||||
changed = true;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ fn part2(input: &str) -> Result<usize> {
|
|||
|
||||
let count = neighbours
|
||||
.iter()
|
||||
.filter(|tile| black_tiles.contains(&tile))
|
||||
.filter(|tile| black_tiles.contains(tile))
|
||||
.count();
|
||||
if black_tiles.contains(&tile) {
|
||||
// Any black tile with zero or more than 2 black tiles immediately adjacent to it is
|
||||
|
|
Loading…
Reference in a new issue