add macros examples

This commit is contained in:
QuietMisdreavus
2017-03-17 09:30:29 -05:00
parent 2079503b21
commit 248d87a2dd
3 changed files with 208 additions and 0 deletions

62
macros/macros1.rs Normal file
View File

@@ -0,0 +1,62 @@
// Make me compile! Scroll down for hints :)
macro_rules! my_macro {
() => {
println!("Check out my macro!");
};
}
fn main() {
my_macro();
}
// When you call a macro, you need to add something special compared to a regular function call. If
// you're stuck, take a look at what's inside `my_macro`.