Warning
This post was published 109 days ago. The information described in this article may have changed.
I'm new to macros, and have a one to which I need to pass a type constructor. This variant works ok:
macro_rules! derive_db_conversions_adl_1 {
($decl:ident) => {
impl<P1: serde::Serialize> crate::db::types::DbConversions
for $decl<P1>
{
...
}
};
}
but taking an :ident
, only accepts an unscoped name. I need to pass a scoped name. Unfortunately using :path
in lieu of :ident
does not compile. ie this:
macro_rules! derive_db_conversions_adl_1 {
($decl:path) => {
impl<P1: serde::Serialize> crate::db::types::DbConversions
for $decl<P1>
{
...
}
};
}
gives the error:
| for $decl<P1>
| ^ expected one of `!`, `+`, `where`, or `{`
|
How can this be done?
Thanks!
3 posts - 3 participants
🏷️ rust_feed