mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-28 06:49:19 +00:00
Complete macros section
This commit is contained in:
parent
b3b9da0fbf
commit
d6a79f2399
@ -8,7 +8,7 @@ macro_rules! my_macro {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
my_macro();
|
||||
my_macro!();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
// macros2.rs
|
||||
// Make me compile! Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
my_macro!();
|
||||
}
|
||||
|
||||
macro_rules! my_macro {
|
||||
() => {
|
||||
println!("Check out my macro!");
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
my_macro!();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// Make me compile, without taking the macro out of the module! Scroll down for hints :)
|
||||
|
||||
mod macros {
|
||||
#[macro_export]
|
||||
macro_rules! my_macro {
|
||||
() => {
|
||||
println!("Check out my macro!");
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
macro_rules! my_macro {
|
||||
() => {
|
||||
println!("Check out my macro!");
|
||||
}
|
||||
};
|
||||
($val:expr) => {
|
||||
println!("Look at this other macro: {}", $val);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user