在 Rust 中,我有时会在 extern crate
语句之前看到 #[macro_use]
:
#[macro_use]
extern crate gotham_derive;
与没有 #[macro_use]
相比,这有什么作用?
extern crate gotham_derive;
最佳答案
这意味着从 crate 中导入(“使用”)宏。
截至Rust 1.30 ,通常不再需要此语法,您可以改用标准的 use
关键字。
查看 macros chapter from the first edition of The Rust Programming Language了解更多详情。
关于rust - extern crate 语句前的#[macro_use] 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54953571/