Trait advent_of_code_traits::ParseInput [−][src]
pub trait ParseInput<const Day: u32> { type Parsed; fn parse_input(input: &str) -> Self::Parsed; }
Implement this trait to parse the the day’s input into a type.
This trait is generic over day.
See ParseEachInput
if you want to use a different input type for each part of a day.
Example Usage
use advent_of_code_traits::{days::Day1, Part1, Part2, ParseInput}; pub struct AdventOfCode2020; impl ParseInput<Day1> for AdventOfCode2020 { type Parsed = Vec<usize>; fn parse_input(input: &str) -> Self::Parsed { // parse your input for day 1 input.lines() .map(|n| n.len()) .collect() } } let part1_input = <AdventOfCode2020 as ParseInput<Day1>>::parse_input("input"); let part2_input = <AdventOfCode2020 as ParseInput<Day1>>::parse_input("input"); // both parts get the same input assert_eq!(part1_input, part2_input);
Associated Types
Loading content...Required methods
fn parse_input(input: &str) -> Self::Parsed
[src]
This function receives the entire input file as a &str slice
and must return a Self::Parsed