From e19c2201f8dab07cb749b2179a36795c66d5359d Mon Sep 17 00:00:00 2001 From: Pascal Phelipot Date: Fri, 1 Dec 2023 20:27:23 +0100 Subject: [PATCH] make rust happy about Capitalized names --- src/day1/mod.rs | 12 ++++++------ src/main.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/day1/mod.rs b/src/day1/mod.rs index b3b264e..f4b5776 100644 --- a/src/day1/mod.rs +++ b/src/day1/mod.rs @@ -1,7 +1,7 @@ -pub enum PART { - ONE, - TWO +pub enum Part { + One, + Two } fn line_to_calibration_part1(line: &str) -> (Option, Option) { @@ -48,12 +48,12 @@ fn line_to_calibration_part2(line: &str) -> (Option, Option) { (a,b) } -pub fn solve(lines: Vec, part: self::PART) -> u32 { +pub fn solve(lines: Vec, part: self::Part) -> u32 { let mut sum = 0; for line in lines.iter() { let (a, b) = match part { - PART::ONE => line_to_calibration_part1(line), - PART::TWO => line_to_calibration_part2(line) + Part::One => line_to_calibration_part1(line), + Part::Two => line_to_calibration_part2(line) }; if let (Some(a), Some(b)) = (a, b) { sum += a * 10 + b; diff --git a/src/main.rs b/src/main.rs index 4b18052..e741713 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,8 +6,8 @@ mod utils; fn main() { let day1_data_path = "./datasets/adventofcode.com_2023_day_1_input.txt"; - let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::ONE); - let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::TWO); + let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::One); + let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::Two); println!("Day 1 (part 1) result is {}", day1_result_part1); println!("Day 1 (part 2) result is {}", day1_result_part2); @@ -21,8 +21,8 @@ mod tests { #[test] fn day1() { let day1_data_path = "./datasets/adventofcode.com_2023_day_1_input.txt"; - let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::ONE); - let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::PART::TWO); + let day1_result_part1 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::One); + let day1_result_part2 = day1::solve(utils::lines_from_file(day1_data_path).expect("Could not load the dataset for day 1"), day1::Part::Two); assert_eq!(day1_result_part1, 54338); assert_eq!(day1_result_part2, 53389);