diff --git a/aoc2015/src/day02.rs b/aoc2015/src/day02.rs index 79aa3ec..874a109 100644 --- a/aoc2015/src/day02.rs +++ b/aoc2015/src/day02.rs @@ -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 { diff --git a/aoc2019/src/day08.rs b/aoc2019/src/day08.rs index 1d6d6d2..8c493d3 100644 --- a/aoc2019/src/day08.rs +++ b/aoc2019/src/day08.rs @@ -84,12 +84,12 @@ impl FromStr for Image { let lines = digits .chunks(IMG_WIDTH) - .map(|chunk| chunk.to_vec()) + .map(<[_]>::to_vec) .collect::>>(); let layers = lines .chunks(IMG_HEIGHT) - .map(|chunk| chunk.to_vec()) + .map(<[_]>::to_vec) .map(|pixels| Layer { pixels }) .collect::>(); diff --git a/aoc2020/src/day20.rs b/aoc2020/src/day20.rs index 39fbf5f..5961c59 100644 --- a/aoc2020/src/day20.rs +++ b/aoc2020/src/day20.rs @@ -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, @@ -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, diff --git a/aoc2020/src/day24.rs b/aoc2020/src/day24.rs index 9992e86..ab6cb28 100644 --- a/aoc2020/src/day24.rs +++ b/aoc2020/src/day24.rs @@ -133,7 +133,7 @@ fn part2(input: &str) -> Result { /// 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::*;