summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-12-07 18:41:51 -0600
committerToby Vincent <tobyv13@gmail.com>2022-12-07 18:41:51 -0600
commite18bd67711510dbdf9254f1811aa76d1cca3abbc (patch)
treed993b2fb30582f9b8d589cc39c66f1f4221e6858 /src/lib.rs
parent6e5439b2aa1ac9707d41729f974b1f3e4d07fc8d (diff)
feat!: impl Problem and Solution traits for all days
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 655815d..04bbb85 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2,28 +2,30 @@
#![feature(iter_next_chunk)]
#![feature(associated_type_defaults)]
-pub trait Solution<'a> {
+pub trait Solution: Problem {
type Answer1: std::fmt::Display + Default = String;
type Answer2: std::fmt::Display + Default = String;
- const DAY: u8;
-
- const INPUT: &'a str;
-
fn part_1(input: &str) -> Result<Self::Answer1, anyhow::Error>;
fn part_2(input: &str) -> Result<Self::Answer2, anyhow::Error>;
fn solve() -> anyhow::Result<()> {
- println!("day {}", Self::DAY);
- println!("part 1: {}", Self::part_1(Self::INPUT)?);
- println!("part 2: {}", Self::part_2(Self::INPUT)?);
+ println!("Day {}", Self::DAY);
+ println!("\tpart 1: {}", Self::part_1(Self::INPUT)?);
+ println!("\tpart 2: {}\n", Self::part_2(Self::INPUT)?);
Ok(())
}
}
+pub trait Problem {
+ const DAY: u8;
+
+ const INPUT: &'static str;
+}
+
pub mod day_1;
pub mod day_2;
pub mod day_3;