Questions tagged «rust-macros»

4
如何在模块文件中使用宏?
我在macro_rules启用了板条箱的同一板条箱中的单独文件中有两个模块。我想使用另一个模块中一个模块中定义的宏。 // macros.rs #[macro_export] // or not? is ineffectual for this, afaik macro_rules! my_macro(...) // something.rs use macros; // use macros::my_macro; <-- unresolved import (for obvious reasons) my_macro!() // <-- how? 我目前遇到了编译器错误“ macro undefined: 'my_macro'” ...,这很有意义;宏系统先于模块系统运行。我该如何解决?
105 module  rust  rust-macros 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.