advent_of_utils/solution.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
use crate::AocOption;
/// Defines the interface for implementing Advent of Code daily puzzle solutions.
/// This trait must be implemented for each day's solution, providing methods
/// to solve both parts of the puzzle.
///
/// # Example
/// ```rust
/// use advent_of_utils::{Solution, AocOption};
///
/// struct Day01 {}
///
/// impl Solution for Day01 {
/// fn part1(&self, input: String) -> AocOption {
/// // Implement solution for part 1
/// 42.into()
/// }
///
/// fn part2(&self, input: String) -> AocOption {
/// // Implement solution for part 2
/// "solution".into()
/// }
/// }
/// ```
pub trait Solution {
/// Solves Part 1 of the daily puzzle.
///
/// # Arguments
/// * `input` - The puzzle input as a string, automatically fetched and cached
/// from Advent of Code.
///
/// # Returns
/// * `AocOption` - The solution result, which can be either:
/// - `AocOption::Int` for numeric answers
/// - `AocOption::Str` for string answers
/// - `AocOption::None` if not implemented (default)
#[allow(unused)]
fn part1(&self, input: String) -> AocOption {
AocOption::None
}
/// Solves Part 2 of the daily puzzle.
///
/// # Arguments
/// * `input` - The puzzle input as a string, automatically fetched and cached
/// from Advent of Code.
///
/// # Returns
/// * `AocOption` - The solution result, which can be either:
/// - `AocOption::Int` for numeric answers
/// - `AocOption::Str` for string answers
/// - `AocOption::None` if not implemented (default)
#[allow(unused)]
fn part2(&self, input: String) -> AocOption {
AocOption::None
}
}