2025: clippies

This commit is contained in:
ktims committed 2026-12-02 14:14:09 -07:00
1 parent 2121d0dc55
commit 0111a3903e
3 files changed
+20 -17

No files matched your search

+12 -5
View File
@@ -22,7 +22,7 @@ fn parse(input: &str) -> Vec<Coord2d> {
}
#[aoc(day9, part1)]
fn part1(input: &Vec<Coord2d>) -> u64 {
fn part1(input: &[Coord2d]) -> u64 {
input
.iter()
.tuple_combinations()
@@ -62,6 +62,7 @@ fn build_grid(reds: &Vec<Coord2d>) -> Grid<u8> {
grid
}
#[allow(unused)]
fn build_hashgrid(reds: &Vec<Coord2d>) -> HashMap<Coord2d, u8> {
let mut grid = HashMap::new();
let mut prev = reds.last().unwrap();
@@ -88,6 +89,7 @@ fn build_hashgrid(reds: &Vec<Coord2d>) -> HashMap<Coord2d, u8> {
grid
}
#[allow(unused)]
fn flood_fill(grid: &mut Grid<u8>, pos: Coord2d) {
if grid.get(&pos) != Some(&b'.') {
return;
@@ -109,6 +111,7 @@ fn flood_fill(grid: &mut Grid<u8>, pos: Coord2d) {
}
}
#[allow(unused)]
fn flood_scan(grid: &mut Grid<u8>, lx: i64, rx: i64, y: i64, q: &mut VecDeque<Coord2d>) {
let mut span_added = false;
for x in lx..rx {
@@ -121,6 +124,7 @@ fn flood_scan(grid: &mut Grid<u8>, lx: i64, rx: i64, y: i64, q: &mut VecDeque<Co
}
}
#[allow(unused)]
// #[aoc(day9, part2, Brute)]
fn part2(reds: &Vec<Coord2d>) -> u64 {
let mut grid = build_grid(reds);
@@ -162,10 +166,11 @@ fn part2(reds: &Vec<Coord2d>) -> u64 {
(a.x().abs_diff(b.x()) + 1) * (a.y().abs_diff(b.y()) + 1)
}
fn line_square_intersection<LT: AsCoord2d, ST: AsCoord2d>(&(l1, l2): &(&LT, &LT), &(sq1, sq2): &(&ST, &ST)) -> bool
#[allow(unused)]
fn line_square_intersection<LT, ST>(&(l1, l2): &(&LT, &LT), &(sq1, sq2): &(&ST, &ST)) -> bool
where
LT: Clone + Display,
ST: Clone + Display,
LT: Clone + Display + AsCoord2d,
ST: Clone + Display + AsCoord2d,
{
let min_x = min(sq1.x(), sq2.x());
let max_x = max(sq1.x(), sq2.x());
@@ -216,6 +221,7 @@ where
trait Rectangle {
fn top_left(&self) -> Coord2d;
fn bottom_right(&self) -> Coord2d;
#[allow(unused)]
fn in_bounds<T: AsCoord2d>(&self, b: &T) -> bool {
b.x() >= self.top_left().x
&& b.x() <= self.bottom_right().x()
@@ -245,6 +251,7 @@ impl Rectangle for (&Coord2d, &Coord2d) {
}
// true = clockwise
#[allow(unused)]
fn outside_points(prev: &Coord2d, cur: &Coord2d, next: &Coord2d) -> Vec<Coord2d> {
let l1_diff = ((cur.x - prev.x).signum(), (cur.y - prev.y).signum());
let l2_diff = ((next.x - cur.x).signum(), (next.y - cur.y).signum());
@@ -269,7 +276,7 @@ fn outside_points(prev: &Coord2d, cur: &Coord2d, next: &Coord2d) -> Vec<Coord2d>
}
#[aoc(day9, part2, Lines)]
fn part2_lines(reds: &Vec<Coord2d>) -> u64 {
fn part2_lines(reds: &[Coord2d]) -> u64 {
// let mut grid = build_hashgrid(reds);
// let mut grid = build_grid(reds);
// // println!("{grid}");