From a3cc3a7efe51b3c9ad4f91b02ade70d865ec289e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sp=C3=B6ttel?= <1682504+fspoettel@users.noreply.github.com> Date: Wed, 22 Nov 2023 14:13:12 +0100 Subject: [PATCH] refactor: rename `main!` macro to `solution!` --- src/template/commands/scaffold.rs | 6 +++--- src/template/mod.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/template/commands/scaffold.rs b/src/template/commands/scaffold.rs index 382283d..2a992bc 100644 --- a/src/template/commands/scaffold.rs +++ b/src/template/commands/scaffold.rs @@ -6,7 +6,9 @@ use std::{ use crate::Day; -const MODULE_TEMPLATE: &str = r#"pub fn part_one(input: &str) -> Option { +const MODULE_TEMPLATE: &str = r#"advent_of_code::solution!(DAY_NUMBER); + +pub fn part_one(input: &str) -> Option { None } @@ -14,8 +16,6 @@ pub fn part_two(input: &str) -> Option { None } -advent_of_code::main!(DAY_NUMBER); - #[cfg(test)] mod tests { use super::*; diff --git a/src/template/mod.rs b/src/template/mod.rs index 215f039..4403b95 100644 --- a/src/template/mod.rs +++ b/src/template/mod.rs @@ -19,9 +19,9 @@ pub fn read_file(folder: &str, day: Day) -> String { f.expect("could not open input file") } -/// main! produces a block setting up the input and runner for each part. +/// Creates the constant `DAY` and sets up the input and runner for each part. #[macro_export] -macro_rules! main { +macro_rules! solution { ($day:expr) => { /// The current day. const DAY: advent_of_code::Day = advent_of_code::day!($day);