π aoc-rust
A tiny, dependency free helper for solving Advent of Code in Rust.
It doesnβt scaffold anything for you: there are no generated files, templates or project layout to adopt. Scaffolding 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: running and timing both parts, downloading inputs and submitting answers.
You write part_one and part_two, and one macro does the rest.
// src/bin/day01.rs
solution!;
Answers can be any type that implements Display, so days with text answers
can return Option<String>.
Running a day looks like this:
$ cargo run --release --bin day01 -- run --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> -- <COMMAND> [OPTIONS]
Commands:
run Run both parts and print the answers
--submit Submit the answer of the highest solved part
--example Use the example input instead of your puzzle input
download Download the puzzle input for the day";
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
Make sure the directories exist before you start, since the crate doesn't create them for you.
Hints
- Shorten the commands you type with an alias or a function of your shell.
- TODO: This repo includes small scripts I personally use to scaffold my project.