y_ich
1
Hi.
I want to make a macro that generates a function name from its arguments.
macro_rule! example {
($i:ident) => (
fn example_$i() {
// some code
}
);
}
example!(AA); // => I want it to generate function example_AA
Is it possible?
1 Like
There's concat_idents!
but that notes its own limitations. AFAICS it doesn't work for declaring a function.
Edit: see concat_idents! and macros in ident position
y_ich
3
Yes, I tried concat_idents, that can generate identifiers already defined, but cannot define...
Thank you.
skade
4
concat_idents! is probably not being stabilized.
https://github.com/rust-lang/rust/issues/29599
For inspirations to tackle this problem using modules, see here: https://github.com/mikkyang/rust-blas/pull/12