I have a situation where I want to genrate code with a macro rules macro that generates code that has an attribute macro applied to it, but it seems that the macro rules macro isn't expanding totally before the attribute macro gets it's tokens. For instance:
macro_rules! testing {
(@test) => {
async fn hello(&self) -> String {
"hello".into()
}
};
() => {
#[Object]
impl ProjectTask {
testing!(@test);
async fn test(&self) -> bool {
false
}
}
};
}
The #[Object]
attribute macro is supposed to read async function signatures and conver them to GraphQL resolver functions, but what I need to do is generate those async function signatures with my macro_rules macro, but it seems that my call to testing!(@test)
doesn't get expanded before the #[Object]
proc macro gets run. It actually does get expanded, but it get's expanded after not before.
Honestly that kind of makes sense, but is there any way to influence the ordering? How can I expand the tokens before I pass them to the #[Object]
macro?