From 9ff562eef94cd34e09abf7197913c3185e90645c Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sun, 11 Dec 2022 13:42:17 +0100 Subject: [PATCH] solution: allow running sample as binary Signed-off-by: Matej Focko --- src/solution.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/solution.rs b/src/solution.rs index 7ea35f3..bae0c7c 100644 --- a/src/solution.rs +++ b/src/solution.rs @@ -19,7 +19,7 @@ pub trait Solution { fn part_1(input: &Input) -> Output; fn part_2(input: &Input) -> Output; - fn main() -> Result<()> + fn run(type_of_input: &str) -> Result<()> where Self: Sized, { @@ -33,13 +33,20 @@ pub trait Solution { .init(); color_eyre::install()?; - let input = Self::parse_input(format!("inputs/{}.txt", Self::day())); + let input = Self::parse_input(format!("{}s/{}.txt", type_of_input, Self::day())); info!("Part 1: {}", Self::part_1(&input)); info!("Part 2: {}", Self::part_2(&input)); Ok(()) } + + fn main() -> Result<()> + where + Self: Sized, + { + Self::run("input") + } } #[macro_export]