π aoc-rust
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.
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.
// src/bin/day01.rs
use Display;
solution!;
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:
[!IMPORTANT] Make sure your session cookie is stored in
~/.adventofcode.sessionor set in theADVENT_OF_CODE_SESSIONenvironment variable.
Usage
Everything you need is in two macros:
-
solution!(year, day)
Turns a file into a runnable day. It generatesmain, which reads the input, runs and timespart_oneandpart_two, prints the answers, and handles therunanddownloadcommands. -
debug!(...)
Works likeeprintln!, but is removed from release builds. Run without--releaseto 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.