cargo-aoc 0.2.0
Summary
Generators & Runners now support Result
s and Option
s in return position.
You can benchmark generators too, using cargo aoc bench -g
.
Input is automatically trimmed.
aoc-runner-derive
no longer flood your doc !
Setup
In your Cargo.toml:
aoc-runner = "0.2.0"
aoc-runner-derive = "0.2.0"
In your terminal:
$ cargo install cargo-aoc --force --version 0.2.0
Examples
#[aoc_generator(day1)]
fn parse_input(input: &str) -> Result<Vec<i32>, ParseIntError> {
input
.lines()
.map(|l| l.parse())
.collect()
}
#[aoc(day1, part1)]
fn part1(freqs: &[i32]) -> i32 {
freqs.iter().sum()
}
Known limitation
By far, the biggest limitation is that I need the return type to be called Result
(it still can be prefixed with a path), with at least a template parameter.
So these wont work :
type MyRes = Result<Vec<i32>, ParseIntError>;
#[aoc_generator(day1)]
fn parse_input(input: &str) -> MyRes {
...
}
type Result = std::result::Result<Vec<i32>, ParseIntError>;
#[aoc_generator(day1)]
fn parse_input(input: &str) -> MyRes {
...
}