I made a simple macro that defines a struct.
macro_rules! __body {
($($body:tt)+) => {
$($body)+
};
}
macro_rules! new_struct {
($(#[$attr:meta])* struct $name:ident { $($body:tt)+ } ) => {
$(#[$attr])* struct $name {
__body!($($body)+);
}
};
}
new_struct! {
#[derive(Deserialize)]
struct Test {
a: bool,
b: String,
}
}
When I compile this code, it raises an error:
|
14 | __body!($($body)+);
| ^ expected `:`
...
19 | / new_struct! {
20 | | #[derive(Deserialize)]
21 | | struct Test {
22 | | a: bool,
23 | | b: String,
24 | | }
25 | | }
| |_- in this macro invocation
|