summaryrefslogtreecommitdiff
path: root/exercises/macros/macros3.rs
diff options
context:
space:
mode:
authorolivia <olivia@fastmail.com>2018-11-09 20:31:14 +0100
committerolivia <olivia@fastmail.com>2018-11-09 20:31:14 +0100
commitf7846af7ac388652a6f80a2bbce926ba8f053062 (patch)
tree954ee36257047ac612654c5f35e18ed27deda97f /exercises/macros/macros3.rs
parent850a13e9133fedb2fce27884902e0aab94da9692 (diff)
right let's try this one again
Diffstat (limited to 'exercises/macros/macros3.rs')
-rwxr-xr-xexercises/macros/macros3.rs75
1 files changed, 75 insertions, 0 deletions
diff --git a/exercises/macros/macros3.rs b/exercises/macros/macros3.rs
new file mode 100755
index 0000000..84c4308
--- /dev/null
+++ b/exercises/macros/macros3.rs
@@ -0,0 +1,75 @@
+// macros3.rs
+// 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.