Make clippy happy

This commit is contained in:
Sijmen 2023-12-06 03:11:21 +01:00
parent e6078af973
commit 64f1b65c9b
1 changed files with 3 additions and 8 deletions

View File

@ -1,6 +1,3 @@
use std::collections::HashSet;
use std::io::{self, BufRead};
fn parse_map(lines: &mut std::str::Lines<'_>) -> Vec<(u64, u64, u64)> { fn parse_map(lines: &mut std::str::Lines<'_>) -> Vec<(u64, u64, u64)> {
let mut map = Vec::new(); let mut map = Vec::new();
@ -33,7 +30,7 @@ fn transform_ranges(map: &[(u64, u64, u64)], ranges: &[(u64, u64)]) -> Vec<(u64,
for (start, length) in ranges { for (start, length) in ranges {
let (dst_start, src_start, len) = map let (dst_start, src_start, len) = map
.iter() .iter()
.find(|(dst, src, len)| src <= start && *start < (src + len)) .find(|(_dst, src, len)| src <= start && *start < (src + len))
.unwrap_or(&(0u64, 0u64, u64::MAX)); .unwrap_or(&(0u64, 0u64, u64::MAX));
let end = start + length; let end = start + length;
@ -52,12 +49,12 @@ fn transform_ranges(map: &[(u64, u64, u64)], ranges: &[(u64, u64)]) -> Vec<(u64,
fn do_the_thing(maps: &Vec<Vec<(u64, u64, u64)>>, mut ranges: Vec<(u64, u64)>) -> u64 { fn do_the_thing(maps: &Vec<Vec<(u64, u64, u64)>>, mut ranges: Vec<(u64, u64)>) -> u64 {
for map in maps { for map in maps {
ranges = transform_ranges(&map, &ranges); ranges = transform_ranges(map, &ranges);
} }
ranges.iter().min().unwrap().0 ranges.iter().min().unwrap().0
} }
fn main() -> io::Result<()> { fn main() {
let mut lines = include_str!("day05.in").lines(); let mut lines = include_str!("day05.in").lines();
let line = lines.next().unwrap(); let line = lines.next().unwrap();
@ -78,6 +75,4 @@ fn main() -> io::Result<()> {
seeds.chunks(2).map(|chunk| (chunk[0], chunk[1])).collect(), seeds.chunks(2).map(|chunk| (chunk[0], chunk[1])).collect(),
); );
dbg!(part1, part2); dbg!(part1, part2);
Ok(())
} }