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

72
macros/macros2.rs Normal file
View File

@@ -0,0 +1,72 @@
// Make me compile! Scroll down for hints :)
fn main() {
my_macro!();
}
macro_rules! my_macro {
() => {
println!("Check out my macro!");
};
}
// Macros don't quite play by the same rules as the rest of Rust, in terms of what's available
// where.
// Unlike other things in Rust, the order of "where you define a macro" versus "where you use it"
// actually matters.