aoc-rust 0.2.0

A tiny ergonomic helper crate for advent-of-code
Documentation

πŸŽ„ aoc-rust

crates.io 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.

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 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:

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.