是否可以在参数位置通过宏调用生成函数参数?这就是我想要实现的目标:
macro_rules! deffn {
(@test-param) => {
test: String,
};
() => {
fn new(
// I need to generated the parameters inside this function (using a macro call)
deffn!(@test-param)
) {
println!("It works");
}
}
}
deffn!();
这是我从编译器得到的输出:
error: expected one of `:` or `|`, found `)`
--> glib/src/param_spec.rs:392:15
|
392 | fn new(
| _______________^
393 | | // I need to generated the parameters inside this function (using a macro call)
394 | | deffn!(@test-param)
| | - expected one of `:` or `|`
395 | | ) {
| |_________^ unexpected token
...
400 | deffn!();
| -------- in this macro invocation
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
= note: this error originates in the macro `deffn` (in Nightly builds, run with -Z macro-backtrace for more info)
help: explicitly ignore the parameter name
|
394 | _: deffn!(@ test - param)
|