+6
-2
.rustlings-state.txt
+6
-2
.rustlings-state.txt
+1
-1
exercises/21_macros/macros1.rs
+1
-1
exercises/21_macros/macros1.rs
+4
-4
exercises/21_macros/macros2.rs
+4
-4
exercises/21_macros/macros2.rs
+1
exercises/21_macros/macros3.rs
+1
exercises/21_macros/macros3.rs
+2
-2
exercises/21_macros/macros4.rs
+2
-2
exercises/21_macros/macros4.rs
+8
-2
solutions/21_macros/macros1.rs
+8
-2
solutions/21_macros/macros1.rs
+8
-2
solutions/21_macros/macros2.rs
+8
-2
solutions/21_macros/macros2.rs
···
1
+
// Moved the macro definition to be before its call.
2
+
macro_rules! my_macro {
3
+
() => {
4
+
println!("Check out my macro!");
5
+
};
6
+
}
7
+
1
8
fn main() {
2
-
// DON'T EDIT THIS SOLUTION FILE!
3
-
// It will be automatically filled after you finish the exercise.
9
+
my_macro!();
4
10
}
+11
-2
solutions/21_macros/macros3.rs
+11
-2
solutions/21_macros/macros3.rs
···
1
+
// Added the attribute `macro_use` attribute.
2
+
#[macro_use]
3
+
mod macros {
4
+
macro_rules! my_macro {
5
+
() => {
6
+
println!("Check out my macro!");
7
+
};
8
+
}
9
+
}
10
+
1
11
fn main() {
2
-
// DON'T EDIT THIS SOLUTION FILE!
3
-
// It will be automatically filled after you finish the exercise.
12
+
my_macro!();
4
13
}
+13
-2
solutions/21_macros/macros4.rs
+13
-2
solutions/21_macros/macros4.rs
···
1
+
// Added semicolons to separate the macro arms.
2
+
#[rustfmt::skip]
3
+
macro_rules! my_macro {
4
+
() => {
5
+
println!("Check out my macro!");
6
+
};
7
+
($val:expr) => {
8
+
println!("Look at this other macro: {}", $val);
9
+
};
10
+
}
11
+
1
12
fn main() {
2
-
// DON'T EDIT THIS SOLUTION FILE!
3
-
// It will be automatically filled after you finish the exercise.
13
+
my_macro!();
14
+
my_macro!(7777);
4
15
}