From 8573d2932d043757bbb4cb22be88237c410f8e0b Mon Sep 17 00:00:00 2001 From: Benjamin Peter Date: Sun, 3 Dec 2023 22:17:27 +0100 Subject: [PATCH] chore: add aoc edition 2023 --- Cargo.toml | 3 ++- aoc-2023/Cargo.toml | 13 +++++++++++++ aoc-2023/src/lib.rs | 7 +++++++ aoc/Cargo.toml | 1 + aoc/src/aoc.rs | 3 ++- aoc/src/cli.rs | 2 +- common/src/day.rs | 2 +- common/src/year.rs | 4 ++-- 8 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 aoc-2023/Cargo.toml create mode 100644 aoc-2023/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index d1206f7..128d152 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] -members = ["aoc", "aoc-2022", "common"] +members = ["aoc", "aoc-2022", "aoc-2023", "common"] +resolver = "2" [workspace.package] authors = ["creberust"] diff --git a/aoc-2023/Cargo.toml b/aoc-2023/Cargo.toml new file mode 100644 index 0000000..25681a7 --- /dev/null +++ b/aoc-2023/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "aoc-2023" +version = "0.1.0" +edition = "2021" +authors.workspace = true +readme.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true +publish.workspace = true + +[dependencies] +common = { version = "0.1.0", path = "../common" } \ No newline at end of file diff --git a/aoc-2023/src/lib.rs b/aoc-2023/src/lib.rs new file mode 100644 index 0000000..44c90d0 --- /dev/null +++ b/aoc-2023/src/lib.rs @@ -0,0 +1,7 @@ +//! Event for the Advent of Code 2023. + +use common::{Event, Year}; + +pub fn event() -> Event { + Event::new(Year::from(2023), [].into_iter()) +} diff --git a/aoc/Cargo.toml b/aoc/Cargo.toml index 7f3ab9c..6274d2f 100644 --- a/aoc/Cargo.toml +++ b/aoc/Cargo.toml @@ -13,6 +13,7 @@ publish.workspace = true [dependencies] aoc-2015 = { version = "0", path = "../aoc-2015" } aoc-2022 = { version = "0", path = "../aoc-2022" } +aoc-2023 = { version = "0", path = "../aoc-2023" } clap = { version = "4.1.8", features = ["derive"] } common = { version = "0.1.0", path = "../common" } log.workspace = true diff --git a/aoc/src/aoc.rs b/aoc/src/aoc.rs index 62e13e6..5f4bb43 100644 --- a/aoc/src/aoc.rs +++ b/aoc/src/aoc.rs @@ -19,6 +19,7 @@ impl AdventOfCode { events: [ (Year::from(2015), aoc_2015::event()), (Year::from(2022), aoc_2022::event()), + (Year::from(2023), aoc_2023::event()), ] .into(), } @@ -34,7 +35,7 @@ impl AdventOfCode { for event in self.events.values() { println!("{}", event); - self.solve_all_days(&event) + self.solve_all_days(event) } } diff --git a/aoc/src/cli.rs b/aoc/src/cli.rs index 040ebb9..57451db 100644 --- a/aoc/src/cli.rs +++ b/aoc/src/cli.rs @@ -8,7 +8,7 @@ pub struct Cli { /// The advent of code event for the given year. /// /// By default, every year will be solved. - #[arg(value_parser = value_parser!(u16).range(2015..=2022))] + #[arg(value_parser = value_parser!(u16).range(2015..=2023))] pub year: Option, /// The day from the selected advent of code event. diff --git a/common/src/day.rs b/common/src/day.rs index 5e5501e..2dd4be1 100644 --- a/common/src/day.rs +++ b/common/src/day.rs @@ -29,7 +29,7 @@ impl Day { impl From for Day { fn from(value: u8) -> Self { - if value < Self::MIN || value > Self::MAX { + if !(Self::MIN..=Self::MAX).contains(&value) { panic!( "Invalid value for Day: {} ∉ [{}, {}]", value, diff --git a/common/src/year.rs b/common/src/year.rs index 425798f..913cded 100644 --- a/common/src/year.rs +++ b/common/src/year.rs @@ -10,7 +10,7 @@ impl Year { /// The minimum year of the Advent of Code event. const MIN: u16 = 2015; /// The maximum recent year of the Advent of Code event. - const MAX: u16 = 2022; + const MAX: u16 = 2023; /// The first year of the Advent of Code event. pub const FIRST: Year = Year(Self::MIN); @@ -27,7 +27,7 @@ impl Year { impl From for Year { fn from(value: u16) -> Self { - if value < Self::MIN || value > Self::MAX { + if !(Self::MIN..=Self::MAX).contains(&value) { panic!( "Invalid value for Year: {} ∉ [{}, {}]", value,