all: fix clippy lints for rust 1.65

This commit is contained in:
Antoine Martin 2022-12-06 01:17:46 +01:00
parent 1d9433098d
commit 008fb72a98
11 changed files with 21 additions and 39 deletions

View file

@ -111,9 +111,8 @@ impl Layout {
count += self
.grid
.get(i)
.map(|line| line.get(j))
.flatten()
.map(|&cell| if cell == value { 1 } else { 0 })
.and_then(|line| line.get(j))
.map(|&cell| u8::from(cell == value))
.unwrap_or(0);
}
@ -131,7 +130,7 @@ impl Layout {
let (i, j) = (i.wrapping_add(di as usize), j.wrapping_add(dj as usize));
let cell = self.grid.get(i).map(|line| line.get(j)).flatten();
let cell = self.grid.get(i).and_then(|line| line.get(j));
match cell {
// keep going, the next seat is farther away

View file

@ -22,8 +22,7 @@ fn part1(input: &str) -> Result<u64> {
Ok(tickets
.iter()
.map(|t| t.invalid_values(&fields_vec))
.flatten()
.flat_map(|t| t.invalid_values(&fields_vec))
.sum())
}
@ -224,7 +223,7 @@ mod tests {
let matches = assign_field_positions(fields, tickets);
let expected = (&["row", "class", "seat"])
let expected = ["row", "class", "seat"]
.iter()
.copied()
.enumerate()

View file

@ -113,7 +113,7 @@ fn mul(input: &str) -> IResult<&str, Expr> {
}
fn num(input: &str) -> IResult<&str, Expr> {
map_res(take_while1(|c: char| c.is_digit(10)), |res: &str| {
map_res(take_while1(|c: char| c.is_ascii_digit()), |res: &str| {
res.parse().map(Expr::Num)
})(input)
}