fix various clippy lints from 1.57

This commit is contained in:
Antoine Martin 2021-12-04 16:55:40 +01:00
parent 239247a8c6
commit d7a77e9283
4 changed files with 6 additions and 21 deletions

View file

@ -29,7 +29,7 @@ fn wrapping_paper(present: &Present) -> u64 {
}
fn part1(presents: &[Present]) -> u64 {
presents.iter().map(|p| wrapping_paper(p)).sum()
presents.iter().map(wrapping_paper).sum()
}
fn ribbon_bow_length(present: &Present) -> u64 {
@ -49,7 +49,7 @@ fn ribbon_needed(present: &Present) -> u64 {
}
fn part2(presents: &[Present]) -> u64 {
presents.iter().map(|p| ribbon_needed(p)).sum()
presents.iter().map(ribbon_needed).sum()
}
struct Present {

View file

@ -84,12 +84,12 @@ impl FromStr for Image {
let lines = digits
.chunks(IMG_WIDTH)
.map(|chunk| chunk.to_vec())
.map(<[_]>::to_vec)
.collect::<Vec<Vec<u8>>>();
let layers = lines
.chunks(IMG_HEIGHT)
.map(|chunk| chunk.to_vec())
.map(<[_]>::to_vec)
.map(|pixels| Layer { pixels })
.collect::<Vec<Layer>>();

View file

@ -59,7 +59,7 @@ enum Rotation {
///
/// Note: we don't need a horizontal and a vertical flip, these result in the same output as a 180
/// degree rotation when combined, so only one is necessary
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Default, Clone, Copy)]
struct Transform {
flip: bool,
rotation: Option<Rotation>,
@ -121,15 +121,6 @@ impl Transform {
}
}
impl Default for Transform {
fn default() -> Self {
Self {
flip: false,
rotation: None,
}
}
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
enum Position {
Down,

View file

@ -133,7 +133,7 @@ fn part2(input: &str) -> Result<usize> {
/// These use the axial coordinates described here:
///
/// https://www.redblobgames.com/grids/hexagons/#coordinates-axial
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)]
struct HexCoordinates {
q: i64,
r: i64,
@ -188,12 +188,6 @@ impl HexCoordinates {
}
}
impl Default for HexCoordinates {
fn default() -> Self {
Self { q: 0, r: 0 }
}
}
#[cfg(test)]
mod tests {
use super::*;