是否可以扩展单个宏而不是整个文件?

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

我刚刚找到了How do I see the expanded macro code that's causing my compile error?。是否可以扩展单个宏而不是整个文件?

rust rust-cargo rust-macros
2个回答
9
投票

cargo-expand命令实际上只是围绕cargo rustc -- -Zunstable-options --pretty=expanded的薄包装,它本身就是一种钝器。您无法定位特定的宏。

但是,从version 0.4开始,您可以通过指定额外的路径参数来扩展该模块使用的宏来减少一些噪音:

$ cargo expand path::to::module

5
投票

“显示扩展的宏”和“显示递归扩展的宏”命令是recently addedIntelliJ Rust

来自CLion blog post的gif演示:

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