···11-fn main() {
22- my_macro!();
33-}
44-51// TODO: Fix the compiler error by moving the whole definition of this macro.
62macro_rules! my_macro {
73 () => {
84 println!("Check out my macro!");
95 };
106}
77+88+fn main() {
99+ my_macro!();
1010+}
+1
exercises/21_macros/macros3.rs
···11// TODO: Fix the compiler error without taking the macro definition out of this
22// module.
33+#[macro_use]
34mod macros {
45 macro_rules! my_macro {
56 () => {
+2-2
exercises/21_macros/macros4.rs
···33macro_rules! my_macro {
44 () => {
55 println!("Check out my macro!");
66- }
66+ };
77 ($val:expr) => {
88 println!("Look at this other macro: {}", $val);
99- }
99+ };
1010}
11111212fn main() {
+8-2
solutions/21_macros/macros1.rs
···11+macro_rules! my_macro {
22+ () => {
33+ println!("Check out my macro!");
44+ };
55+}
66+17fn main() {
22- // DON'T EDIT THIS SOLUTION FILE!
33- // It will be automatically filled after you finish the exercise.
88+ my_macro!();
99+ // ^
410}
+8-2
solutions/21_macros/macros2.rs
···11+// Moved the macro definition to be before its call.
22+macro_rules! my_macro {
33+ () => {
44+ println!("Check out my macro!");
55+ };
66+}
77+18fn main() {
22- // DON'T EDIT THIS SOLUTION FILE!
33- // It will be automatically filled after you finish the exercise.
99+ my_macro!();
410}
+11-2
solutions/21_macros/macros3.rs
···11+// Added the attribute `macro_use` attribute.
22+#[macro_use]
33+mod macros {
44+ macro_rules! my_macro {
55+ () => {
66+ println!("Check out my macro!");
77+ };
88+ }
99+}
1010+111fn main() {
22- // DON'T EDIT THIS SOLUTION FILE!
33- // It will be automatically filled after you finish the exercise.
1212+ my_macro!();
413}
+13-2
solutions/21_macros/macros4.rs
···11+// Added semicolons to separate the macro arms.
22+#[rustfmt::skip]
33+macro_rules! my_macro {
44+ () => {
55+ println!("Check out my macro!");
66+ };
77+ ($val:expr) => {
88+ println!("Look at this other macro: {}", $val);
99+ };
1010+}
1111+112fn main() {
22- // DON'T EDIT THIS SOLUTION FILE!
33- // It will be automatically filled after you finish the exercise.
1313+ my_macro!();
1414+ my_macro!(7777);
415}