Rust 外部板条箱语句之前的#[macro_use]是什么意思?
在《铁锈》中,我有时会在Rust 外部板条箱语句之前的#[macro_use]是什么意思?,rust,Rust,在《铁锈》中,我有时会在外部板条箱语句之前看到#[macro\u use]: #[macro_use] extern crate gotham_derive; 与没有#[macro\u use]相比,这有什么作用 extern crate gotham_derive; 这意味着从板条箱中导入(“使用”)宏 到目前为止,通常不再需要此语法,您可以使用标准的use关键字 查看以了解更多详细信息。我对Rust的宏不太熟悉,但Rust 2015中需要使用[macro\u use]来通知编译器您正在使
外部板条箱
语句之前看到#[macro\u use]
:
#[macro_use]
extern crate gotham_derive;
与没有#[macro\u use]
相比,这有什么作用
extern crate gotham_derive;
这意味着从板条箱中导入(“使用”)宏
到目前为止,通常不再需要此语法,您可以使用标准的use
关键字
查看以了解更多详细信息。我对Rust的宏不太熟悉,但Rust 2015中需要使用
[macro\u use]
来通知编译器您正在使用机箱中定义的宏。我尝试使用1use serde\u derive;`而不是#[macro_use]外部板条箱serde_代码>但是失败了@HasanAYousef使用serde_
是一个no-op,就像任何use
语句中没有:
一样。您可能想要使用serde_派生::{反序列化,序列化}代码>或类似。