macro_rules! year { ($year:literal => $crate_name:ident, $dollar:tt{$( $day:literal => $day_mod:ident::$day_struct:ident$(<$lifetime:lifetime>)?, )+}) => { ... }; }
Expand description
Macro to generate the crate root for each year crate, implementing common items.
For each day, the module is declared, the struct re-exported and the Puzzle
trait
implemented.
A puzzle!
macro is defined and exported, which takes one or more callback macro paths and a
list of arguments captured as tt
fragments. The macro expands to calling the first callback
with the remaining callback paths and the provided arguments followed by the year number, crate
name and a list of day numbers and structs. These macros are then chained across all year
crates to implement aoc::all_puzzles!
.
Running cargo xtask update
will automatically update the list of days inside macro invocations
in files matching crates/year????/src/lib.rs
.
§Examples
ⓘ
utils::year!(2015 => year2015, ${
1 => day01::Day01,
2 => day02::Day02,
});