Crate yaah

source ·
Expand description

yaah – Yet Another AOC Helper for your Advent Of Code adventures

This crate handles the boilerplate around fetching, running and benchmarking your input parsing and solution implementations. It is inpired by the excellent cargo-aoc cargo extentions.

Setup

This helper will automatically fetch your personnal input file provided you set your AOC session cookie in the AOC_SESSION environment variable. This can be either done through your favorite shell or in a .cargo/config.toml file as such:

[env]
AOC_SESSION = "your super long session secret extracted from your browser's cookie jar"

Note that this .cargo directory can reside in a parent directory of your project allowing you to have a project specific version controlled cargo config file without leaking your session secret.

If you want to benefit from the auto-generated main function, you will need to add a dependency to clap.

clap = { version = "4.0", features = ["derive"] }

If you want to benefit from the auto-generated bench marks, your project’s manifest will require these extra elements:

[dependencies]
criterion = "0.4.0"

[[bench]]
name = "aoc-bench"
harness = false

For your convenience a template project is availble. Simply bootstrap your Advent of code with:

cargo generate --git https://github.com/ithinuel/yaah-template.git

Macros

Generates the benchmarks
Generates the solver methods used by the main function and the benchmarks.
Generates the main function
Sets the year for the solutions

Attribute Macros

Attribute for the solver functions
Attribute for the generator functions