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

问题描述 投票:-1回答:1

在Rust中,我有时会在#[macro_use]声明之前看到extern crate

#[macro_use]
extern crate gotham_derive;

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

extern crate gotham_derive;
rust
1个回答
2
投票

它意味着从包中导入(“使用”)宏。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.