aoc_framework 0.1.0

A framework used to run Advent of Code Challenges
Documentation
/// Trait for a challenge
/// It is generic over `R` which is the type of the result.
/// So this trait can be implemented for challenges with different result types (eg. Integers or Strings).
/// The trait implements two functions, `part1` and `part2`, which are used to provide the solution to the respective part of the challenge.
/// 
/// The functions take a `Vec<String>` as input and return an `Option<R>`.
/// The input is the input data for the challenge and is provided by the `InputLoader`.
/// 
/// The functions return an `Option<R>` because the challenge might not be implemented for the respective part.
/// If the challenge is not implemented, the function should return `None`.
/// 
/// The function also take a mutable reference to `self` as input.
/// 
/// The Object implementing this trait is used to provide the solution to the challenge.
/// This object is created by the user and passed to the `AOCRunner`.
/// 
/// # Examples
/// ```
/// use aoc_runner::{Challenge, ChallengePart};
/// struct Solution;
/// 
/// impl Challenge<i32> for Solution {
///    fn part1(&mut self, input: Vec<String>) -> Option<i32> {
///       Some(0)
///   }
/// }
/// 
/// fn main() {
///   AOCRunner::new(Solution::new())
///     .run(from_file("input.txt")); //Returns 0 for first part of the challenge. Then asks for feedback. Then states that the second part is not implemented.
/// }
pub trait Challenge<R> {
    /// Provides the solution to the first part of the challenge.
    fn part1(&mut self, _input: Vec<String>) -> Option<R> {
        None
    }

    /// Provides the solution to the second part of the challenge.
    fn part2(&mut self, _input: Vec<String>) -> Option<R> {
        None
    }
}

/// Enum for the two parts of the challenge
/// Used to provide the part of the challenge when adding examples
#[derive(Debug, PartialEq, Eq)]
pub enum ChallengePart {
    Part1,
    Part2
}

impl ChallengePart {
    pub fn to_number(&self) -> i32 {
        match self {
            ChallengePart::Part1 => 1,
            ChallengePart::Part2 => 2
        }
    }
}