Skip to content

cargo-aoc 0.2.0

Compare
Choose a tag to compare
@gobanos gobanos released this 06 Dec 00:46
· 91 commits to master since this release
3f0261a

Summary

Generators & Runners now support Results and Options 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 {
    ...
}

link to the doc