2018-02-22 06:09:53 +00:00
|
|
|
// macros3.rs
|
2017-03-17 14:30:29 +00:00
|
|
|
// Make me compile, without taking the macro out of the module! Scroll down for hints :)
|
|
|
|
|
|
|
|
mod macros {
|
|
|
|
macro_rules! my_macro {
|
|
|
|
() => {
|
|
|
|
println!("Check out my macro!");
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
my_macro!();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-19 14:10:48 +00:00
|
|
|
// In order to use a macro outside of its module, you need to do something
|
|
|
|
// special to the module to lift the macro out into its parent.
|
2017-03-17 14:30:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-19 14:10:48 +00:00
|
|
|
// The same trick also works on "extern crate" statements for crates that have
|
|
|
|
// exported macros, if you've seen any of those around.
|