From 9845e046de6f9569519d0e0ae3c50341eb35a8bf Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 1 Jul 2024 11:31:37 +0200 Subject: [PATCH] macros2 solution --- exercises/21_macros/macros2.rs | 1 + solutions/21_macros/macros2.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/exercises/21_macros/macros2.rs b/exercises/21_macros/macros2.rs index f16712be..2d9dec76 100644 --- a/exercises/21_macros/macros2.rs +++ b/exercises/21_macros/macros2.rs @@ -2,6 +2,7 @@ fn main() { my_macro!(); } +// TODO: Fix the compiler error by moving the whole definition of this macro. macro_rules! my_macro { () => { println!("Check out my macro!"); diff --git a/solutions/21_macros/macros2.rs b/solutions/21_macros/macros2.rs index 4e181989..b6fd5d2c 100644 --- a/solutions/21_macros/macros2.rs +++ b/solutions/21_macros/macros2.rs @@ -1 +1,10 @@ -// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 +// Moved the macro definition to be before its call. +macro_rules! my_macro { + () => { + println!("Check out my macro!"); + }; +} + +fn main() { + my_macro!(); +}