在Rust中,我有时会在#[macro_use]
声明之前看到extern crate
:
#[macro_use]
extern crate gotham_derive;
与没有#[macro_use]
相比,这有什么作用?
extern crate gotham_derive;
它意味着从包中导入(“使用”)宏。
从Rust 1.30开始,通常不再需要此语法,您可以使用标准的use
关键字。
查看macros chapter from the first edition of The Rust Programming Language了解更多详情。