summaryrefslogtreecommitdiff
path: root/macros/macros3.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/macros3.rs')
-rw-r--r--macros/macros3.rs74
1 files changed, 74 insertions, 0 deletions
diff --git a/macros/macros3.rs b/macros/macros3.rs
new file mode 100644
index 0000000..8d8da38
--- /dev/null
+++ b/macros/macros3.rs
@@ -0,0 +1,74 @@
+// 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!();
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// 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.
+
+
+
+
+
+
+
+
+// The same trick also works on "extern crate" statements for crates that have exported macros, if
+// you've seen any of those around.