From 39dcd550a7f0ee6a93f5bcd76d3d433778e84674 Mon Sep 17 00:00:00 2001 From: David Bailey <davidbailey00@outlook.com> Date: Sun, 17 Jan 2021 00:19:45 +0000 Subject: [PATCH] Add macros solutions --- exercises/macros/macros1.rs | 4 +--- exercises/macros/macros2.rs | 10 ++++------ exercises/macros/macros3.rs | 3 +-- exercises/macros/macros4.rs | 6 ++---- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/exercises/macros/macros1.rs b/exercises/macros/macros1.rs index ed0dac8..de2584a 100644 --- a/exercises/macros/macros1.rs +++ b/exercises/macros/macros1.rs @@ -1,8 +1,6 @@ // macros1.rs // Make me compile! Execute `rustlings hint macros1` for hints :) -// I AM NOT DONE - macro_rules! my_macro { () => { println!("Check out my macro!"); @@ -10,5 +8,5 @@ macro_rules! my_macro { } fn main() { - my_macro(); + my_macro!(); } diff --git a/exercises/macros/macros2.rs b/exercises/macros/macros2.rs index d0be123..a931064 100644 --- a/exercises/macros/macros2.rs +++ b/exercises/macros/macros2.rs @@ -1,14 +1,12 @@ // macros2.rs // Make me compile! Execute `rustlings hint macros2` for hints :) -// I AM NOT DONE - -fn main() { - my_macro!(); -} - macro_rules! my_macro { () => { println!("Check out my macro!"); }; } + +fn main() { + my_macro!(); +} diff --git a/exercises/macros/macros3.rs b/exercises/macros/macros3.rs index 93a4311..868f3dd 100644 --- a/exercises/macros/macros3.rs +++ b/exercises/macros/macros3.rs @@ -2,8 +2,7 @@ // Make me compile, without taking the macro out of the module! // Execute `rustlings hint macros3` for hints :) -// I AM NOT DONE - +#[macro_use] mod macros { macro_rules! my_macro { () => { diff --git a/exercises/macros/macros4.rs b/exercises/macros/macros4.rs index 3a74807..5608ecc 100644 --- a/exercises/macros/macros4.rs +++ b/exercises/macros/macros4.rs @@ -1,15 +1,13 @@ // macros4.rs // Make me compile! Execute `rustlings hint macros4` for hints :) -// I AM NOT DONE - macro_rules! my_macro { () => { println!("Check out my macro!"); - } + }; ($val:expr) => { println!("Look at this other macro: {}", $val); - } + }; } fn main() {