feat: add macro arms for running individual parts of a solution (#44)
This commit is contained in:
parent
9d064019c3
commit
df48bfe6ec
1 changed files with 22 additions and 0 deletions
|
@ -34,6 +34,8 @@ pub fn read_file_part(folder: &str, day: Day, part: u8) -> String {
|
|||
}
|
||||
|
||||
/// Creates the constant `DAY` and sets up the input and runner for each part.
|
||||
///
|
||||
/// The optional, second parameter (1 or 2) allows you to only run a single part of the solution.
|
||||
#[macro_export]
|
||||
macro_rules! solution {
|
||||
($day:expr) => {
|
||||
|
@ -47,4 +49,24 @@ macro_rules! solution {
|
|||
run_part(part_two, &input, DAY, 2);
|
||||
}
|
||||
};
|
||||
($day:expr, 1) => {
|
||||
/// Allows solving part one in isolation
|
||||
const DAY: advent_of_code::template::Day = advent_of_code::day!($day);
|
||||
|
||||
fn main() {
|
||||
use advent_of_code::template::runner::*;
|
||||
let input = advent_of_code::template::read_file("inputs", DAY);
|
||||
run_part(part_one, &input, DAY, 1);
|
||||
}
|
||||
};
|
||||
($day:expr, 2) => {
|
||||
/// Allows solving part two in isolation
|
||||
const DAY: advent_of_code::template::Day = advent_of_code::day!($day);
|
||||
|
||||
fn main() {
|
||||
use advent_of_code::template::runner::*;
|
||||
let input = advent_of_code::template::read_file("inputs", DAY);
|
||||
run_part(part_two, &input, DAY, 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue