extern crate语句前的#[macro_use]是什么意思?

时间:2019-03-01 23:13:51

标签: rust

在Rust中,有时在#[macro_use]语句之前会看到extern crate

#[macro_use]
extern crate gotham_derive;

与没有#[macro_use]相比,这有什么作用?

extern crate gotham_derive;

1 个答案:

答案 0 :(得分:2)

这意味着从板条箱中导入(“使用”)宏。

Rust 1.30开始,通常不再需要此语法,而可以使用标准的use关键字。

查看macros chapter from the first edition of The Rust Programming Language以获得更多详细信息。