我知道$crate变量是什么,但据我所知,它不能在程序宏中使用.还有另一种方法可以达到类似的效果吗?
我有一个例子,大致要求我用引号和每晚Rust 写这样的东西
quote!(
struct Foo {
bar: [SomeTrait;#len]
}
)
Run Code Online (Sandbox Code Playgroud)
我需要确保SomeTrait在范围内(#len引用一个超出代码段范围的整数).
小智 10
从 Rust 1.34 开始,您可以使用extern crate self as my_crate, 并使用my_crate::Foo代替$crate::Foo.
https://github.com/rust-lang/rust/issues/54647
https://github.com/rust-lang/rust/pull/57407
(来源:Neptunepink ##rust irc.freenode.net)
根据https://github.com/rust-lang/rust/issues/38356#issuecomment-412920528的回复,看起来没有办法做到这一点(截至2018-08),也没有参考过程-macro crate 也不能明确引用任何其他 crate。
| 归档时间: |
|
| 查看次数: |
805 次 |
| 最近记录: |