# π aoc-rust
[](https://crates.io/crates/aoc-rust)
[](LICENSE)
A small Advent of Code helper for Rust with no crate dependencies. It fetches your input, runs and times both parts, and submits answers. Network requests are handled by [aoc-cli](https://github.com/scarvalhojr/aoc-cli).
It doesnβt scaffold anything for you. Scaffolding and downloading is easy to do with a small script, so the crate leaves it to you. You create your day files yourself, and the crate only adds the convenience around them.
You write part_one and part_two, and one macro does the rest.
```rust
// src/bin/day01.rs
use std::fmt::Display;
aoc_rust::solution!(2025, 1);
fn part_one(input: &str) -> Option<impl Display> { None::<u64> }
fn part_two(_input: &str) -> Option<impl Display> { None::<u64> }
```
Running a day looks like this:
```
$ cargo run --release --bin day01 -- --submit
2025 Day 1:
Part 1: 1 333ns
Part 2: unsolved
Submitting "1" for part 1:
*\(^o^)/* That's the correct answer!
```
## Setup
Add it to the project you solve puzzles in and make sure the aoc-cli is installed:
```sh
cargo add aoc-rust
cargo install aoc-cli --version 0.12.0
```
> [!IMPORTANT]
> Make sure your session cookie is stored in `~/.adventofcode.session` or set in the
> `ADVENT_OF_CODE_SESSION` environment variable.
## Usage
Everything you need is in two macros:
- `solution!(year, day)`\
Turns a file into a runnable day. It generates `main`, which reads the input,
runs and times `part_one` and `part_two`, prints the answers, and handles the
`run` and `download` commands.
- `debug!(...)`\
Works like `eprintln!`, but is removed from release builds. Run without
`--release` to see the output.
## Commands
```
Usage: cargo run [--release] --bin <DAY> -- [OPTIONS]
Options:
--help (-h) Print help.
--submit (-s) Submit the answer of the highest solved part
--example (-e) Use the example input instead of your puzzle input
```
## Files
Inputs live next to your `Cargo.toml`:
```
my-adventofcode/
βββ Cargo.toml
βββ src/
β βββ bin/
β βββ day01.rs # aoc_rust::solution!(2025, 1);
β βββ day02.rs # aoc_rust::solution!(2025, 2);
βββ data/
βββ inputs/
β βββ day01.txt # your puzzle input (downloaded)
β βββ day02.txt
βββ examples/
βββ day01.txt # the example from the puzzle text (paste it yourself)
βββ day02.txt
```
## Hints
- Use the aoc-cli to download inputs.
- Shorten the commands you type with an alias or a function of your shell.