Macros 如何在模块中定义和使用宏?
当我试图在代码中定义宏时,编译器会这样说:Macros 如何在模块中定义和使用宏?,macros,rust,Macros,Rust,当我试图在代码中定义宏时,编译器会这样说: refix/mod.rs:12:1: 12:12 error: macro definitions are not stable enough for use and are subject to change refix/mod.rs:12 macro_rules! re_fix( ^~~~~~~~~~~ refix/mod.rs:12:1: 12:12 note: add #[feature(macro_rules)
refix/mod.rs:12:1: 12:12 error: macro definitions are not stable enough for use and are subject to change
refix/mod.rs:12 macro_rules! re_fix(
^~~~~~~~~~~
refix/mod.rs:12:1: 12:12 note: add #[feature(macro_rules)] to the crate attributes to enable
refix/mod.rs:12 macro_rules! re_fix(
我添加了很多#[功能(宏规则)]
,但没有任何帮助
源代码:
PS:是的,可能还有很多其他的错误,但我对这个很感兴趣。我认为这个错误信息有点误导。您必须添加
#![功能(宏规则)]
到您的主板条箱模块(注意感叹号),以及#![板条箱id=…]
和其他
#![crate_id="rsfix#0.0"]
#![feature(macro_rules)]
macro_rules! example( ... )
fn main() {
example!(...);
}
这应该适用于最新的编译器版本