feat: return option from solution parts

this allows to print _not solved_ for solution parts that haven't been solved yet.

adjust `solve` macro to handle one solution part rather than both.
this allows for easier debugging of real input.
This commit is contained in:
Felix Spöttel
2022-10-29 17:04:13 +02:00
parent 9eb5e488e2
commit ec5859083a
3 changed files with 25 additions and 21 deletions

View File

@@ -4,16 +4,18 @@ use std::{
process,
};
const MODULE_TEMPLATE: &str = r###"pub fn part_one(input: &str) -> u32 {
0
const MODULE_TEMPLATE: &str = r###"pub fn part_one(input: &str) -> Option<u32> {
None
}
pub fn part_two(input: &str) -> u32 {
0
pub fn part_two(input: &str) -> Option<u32> {
None
}
fn main() {
aoc::solve!(&aoc::read_file("inputs", DAY), part_one, part_two)
let input = &aoc::read_file("inputs", DAY);
aoc::solve!(1, part_one, input);
aoc::solve!(2, part_two, input);
}
#[cfg(test)]
@@ -24,14 +26,14 @@ mod tests {
fn test_part_one() {
use aoc::read_file;
let input = read_file("examples", DAY);
assert_eq!(part_one(&input), 0);
assert_eq!(part_one(&input), None);
}
#[test]
fn test_part_two() {
use aoc::read_file;
let input = read_file("examples", DAY);
assert_eq!(part_two(&input), 0);
assert_eq!(part_two(&input), None);
}
}
"###;