rust - extern crate 语句之前的#[macro_use] 是什么意思?
问题描述
在 Rust 中,我有时会#[macro_use]
在extern crate
语句之前看到:
#[macro_use]
extern crate gotham_derive;
与没有相比,这有什么作用#[macro_use]
?
extern crate gotham_derive;
解决方案
这意味着从 crate 中导入(“使用”)宏。
从Rust 1.30开始,通常不再需要这种语法,您可以改用标准use
关键字。
查看The Rust Programming Language第一版中的宏章节以获取更多详细信息。
推荐阅读
- mongodb - MongoDb无需认证即可访问
- r - 是否可以在 R 中找到 GUI 的源代码?
- javascript - 如何在数组 JavaScript 中定义一些东西
- tinymce - 如果您更改了 TinyMce 中的样式格式标题,如何覆盖字体大小
- zip - 使用 shell 脚本构建可执行的 zip
- c# - GoogleWebAuthorizationBroker.AuthorizeAsync 出错
- arrays - 更新 MongoDB 中的多个条件数组
- arrays - 快速重新排序二维数组
- javascript - 添加 jQuery 导轨 6.1
- reactjs - 使用 NextJS 内置 i18n 检测浏览器语言