Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Rust 外部板条箱语句之前的#[macro_use]是什么意思?_Rust - Fatal编程技术网

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_派生::{反序列化,序列化}或类似。