是否可以扩展单个宏而不是整个文件? [英] Is it possible to get the expansion of a single macro instead of the whole file?

查看:48
本文介绍了是否可以扩展单个宏而不是整个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现 如何查看导致编译错误的扩展宏代码?.是否可以扩展单个宏而不是整个文件?

I just found How do I see the expanded macro code that's causing my compile error?. Is it possible to get the expansion of a single macro instead of the whole file?

推荐答案

cargo-expand 命令实际上只是 cargo rustc -- -Zunstable-options --pretty=expanded 的一个薄包装器,它本身就是一个钝器.您不能针对特定的宏.

The cargo-expand command is really just a thin wrapper around cargo rustc -- -Zunstable-options --pretty=expanded, which is itself a blunt instrument. You can't target a specific macro.

但是,由于 0.4 版,您可以减少通过指定额外的路径参数以仅扩展该模块使用的宏来产生一些噪音:

However, since version 0.4, you can reduce some noise by specifying an extra path argument to expand only macros used by that module:

$ cargo expand path::to::module

这篇关于是否可以扩展单个宏而不是整个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆