fix various clippy lints from 1.57
This commit is contained in:
parent
239247a8c6
commit
d7a77e9283
|
@ -29,7 +29,7 @@ fn wrapping_paper(present: &Present) -> u64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part1(presents: &[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 {
|
fn ribbon_bow_length(present: &Present) -> u64 {
|
||||||
|
@ -49,7 +49,7 @@ fn ribbon_needed(present: &Present) -> u64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part2(presents: &[Present]) -> u64 {
|
fn part2(presents: &[Present]) -> u64 {
|
||||||
presents.iter().map(|p| ribbon_needed(p)).sum()
|
presents.iter().map(ribbon_needed).sum()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Present {
|
struct Present {
|
||||||
|
|
|
@ -84,12 +84,12 @@ impl FromStr for Image {
|
||||||
|
|
||||||
let lines = digits
|
let lines = digits
|
||||||
.chunks(IMG_WIDTH)
|
.chunks(IMG_WIDTH)
|
||||||
.map(|chunk| chunk.to_vec())
|
.map(<[_]>::to_vec)
|
||||||
.collect::<Vec<Vec<u8>>>();
|
.collect::<Vec<Vec<u8>>>();
|
||||||
|
|
||||||
let layers = lines
|
let layers = lines
|
||||||
.chunks(IMG_HEIGHT)
|
.chunks(IMG_HEIGHT)
|
||||||
.map(|chunk| chunk.to_vec())
|
.map(<[_]>::to_vec)
|
||||||
.map(|pixels| Layer { pixels })
|
.map(|pixels| Layer { pixels })
|
||||||
.collect::<Vec<Layer>>();
|
.collect::<Vec<Layer>>();
|
||||||
|
|
||||||
|
|
|
@ -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
|
/// 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
|
/// degree rotation when combined, so only one is necessary
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Default, Clone, Copy)]
|
||||||
struct Transform {
|
struct Transform {
|
||||||
flip: bool,
|
flip: bool,
|
||||||
rotation: Option<Rotation>,
|
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)]
|
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||||
enum Position {
|
enum Position {
|
||||||
Down,
|
Down,
|
||||||
|
|
|
@ -133,7 +133,7 @@ fn part2(input: &str) -> Result<usize> {
|
||||||
/// These use the axial coordinates described here:
|
/// These use the axial coordinates described here:
|
||||||
///
|
///
|
||||||
/// https://www.redblobgames.com/grids/hexagons/#coordinates-axial
|
/// 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 {
|
struct HexCoordinates {
|
||||||
q: i64,
|
q: i64,
|
||||||
r: i64,
|
r: i64,
|
||||||
|
@ -188,12 +188,6 @@ impl HexCoordinates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for HexCoordinates {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self { q: 0, r: 0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue