aoc-toolbox
📖 About
aoc-toolbox is a Rust library designed to simplify your Advent of Code experience. With this toolbox, you can:
- Mark your solvers with minimal boilerplate.
- Automatically generate a main function with argument parsing.
📦 Installation
Add the following dependency:
🚀 Usage
1. Mark Your Solvers
Use the #[aoc_solver] macro to annotate your solver functions. For example:
use aoc_solver;
2. Generate the Main Function
Use the aoc_main! macro in your main.rs file to tie everything together:
use aoc_main;
aoc_main!
How It Works
The aoc_main! macro will generate a main function that:
- Parses the command-line arguments.
- Runs the specified solver for the selected day and part.
Example Command
cargo run -- --day 1 --part 1 < input.txt
⚠️ Limitations
- Macro State: Rust macros do not currently share state between calls (see this issue). A workaround is implemented, but it may lead to unexpected behavior.
- Solver Signature: Each solver function must take a
Stringas input and also return aString.
💡 Motivation
This tool was initially created for personal use during Advent of Code, but it's now available for anyone who finds it helpful. Enjoy hacking away at those puzzles! 🎄✨