是否可以在Rust宏中生成符号或标识符
我想生成一个给定符号的方法,但需要对其进行降级
get!(B);
// should expand to
fn b() -> B {
// method body
}
很容易接近...
macro_rules! get {
($kind:ident, $method:ident)
=>
{
fn $method() -> $kind {
// method body
}
}
}
get!(B, b)
但令人不满.