From cc2c0958c9ba038e1584f3cbff0b07df4cc490c1 Mon Sep 17 00:00:00 2001 From: mo8it Date: Mon, 1 Jul 2024 11:54:05 +0200 Subject: [PATCH] macros4 solution --- exercises/21_macros/macros4.rs | 1 + solutions/21_macros/macros4.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/exercises/21_macros/macros4.rs b/exercises/21_macros/macros4.rs index 03ece080..9d77f6a5 100644 --- a/exercises/21_macros/macros4.rs +++ b/exercises/21_macros/macros4.rs @@ -1,3 +1,4 @@ +// TODO: Fix the compiler error by adding one or two characters. #[rustfmt::skip] macro_rules! my_macro { () => { diff --git a/solutions/21_macros/macros4.rs b/solutions/21_macros/macros4.rs index 4e181989..41bcad16 100644 --- a/solutions/21_macros/macros4.rs +++ b/solutions/21_macros/macros4.rs @@ -1 +1,15 @@ -// Solutions will be available before the stable release. Thank you for testing the beta version 🥰 +// Added semicolons to separate the macro arms. +#[rustfmt::skip] +macro_rules! my_macro { + () => { + println!("Check out my macro!"); + }; + ($val:expr) => { + println!("Look at this other macro: {}", $val); + }; +} + +fn main() { + my_macro!(); + my_macro!(7777); +}