summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2023-12-30 14:10:54 -0600
committerToby Vincent <tobyv@tobyvin.dev>2023-12-30 14:10:54 -0600
commitbd2bf0b92964706a449defd3a905a35845f3d7d2 (patch)
treecf18e93af2b60bea934a0bc2f72f976f55fd34be
parent6f88481aa6242007d1815060388f530be4a13b81 (diff)
fix: fix error in days macro
-rw-r--r--src/lib.rs14
-rw-r--r--src/main.rs2
2 files changed, 6 insertions, 10 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 54ce211..ce7331a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,7 +5,6 @@
array_windows,
iter_intersperse,
impl_trait_in_assoc_type,
- macro_metavar_expr,
slice_group_by
)]
@@ -33,24 +32,21 @@ pub use printer::Printer;
pub type Result<T, E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
-#[macro_export]
-macro_rules! get_days {
- // `()` indicates that the macro takes no argument.
+macro_rules! days {
($($day:path),*) => {
- pub fn get_days() -> [(&'static str, [Box<dyn Fn(&str) -> anyhow::Result<usize>>; 2]); ${count(day)}] {
- [
+ pub fn days() -> Vec<(&'static str, [Box<dyn Fn(&str) -> anyhow::Result<usize>>; 2])> {
+ vec![
$((<$day>::INPUT,
[
Box::new(<$day>::part_1),
Box::new(<$day>::part_2),
- ])
- ,)*
+ ]),)*
]
}
};
}
-get_days!(
+days!(
day_01::Day01,
day_02::Day02,
day_03::Day03,
diff --git a/src/main.rs b/src/main.rs
index 0883c66..acee1df 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,6 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut args = std::env::args().skip(1);
- let days = aoc_2023::get_days();
+ let days = aoc_2023::days();
let days_n = if let Some(first) = args.next() {
if "all".contains(first.as_str()) {