gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 08:26:36 25 4
gpt4 key购买 nike

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

#[macro_use]
extern crate gotham_derive;

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

extern crate gotham_derive;

最佳答案

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

截至Rust 1.30 ,通常不再需要此语法,您可以改用标准的 use 关键字。

查看 macros chapter from the first edition of The Rust Programming Language了解更多详情。

关于rust - extern crate 语句前的#[macro_use] 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54953571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com