Skip to content

Commit 565fc8e

Browse files
committed
// macros3.rs
// // Make me compile, without taking the macro out of the module! // // Execute `rustlings hint macros3` or use the `hint` watch subcommand for a // hint. // I AM NOT DONE // 使用 #[macro_use] 导出模块内的宏,使其在外部可调用 #[macro_use] mod macros { macro_rules! my_macro { () => { println!("Check out my macro!"); }; } } fn main() { my_macro!(); }
1 parent 644b0e6 commit 565fc8e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

exercises/macros/macros3.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
// I AM NOT DONE
99

10+
// 使用 #[macro_use] 导出模块内的宏,使其在外部可调用
11+
#[macro_use]
1012
mod macros {
1113
macro_rules! my_macro {
1214
() => {
@@ -18,3 +20,4 @@ mod macros {
1820
fn main() {
1921
my_macro!();
2022
}
23+

0 commit comments

Comments
 (0)