Looking up syntax for struct based on identifier passed to procedural macro

⚓ Rust    📅 2025-11-25    👤 surdeus    👁️ 7      

surdeus

I am learning syn and was wondering if I am able to look up struct syntax based only on the struct identifier as syntax input to a procedural macro without using a derive or attribute proc macro.

For example:

struct Ab {
a: f32,
b: u32 }

my_macro!(Ab)

Should look up if the struct Ab exists in the file and then turn the syntax into a TokenStream.

Which would be equivalent to

my_macro!(
struct Ab {
a: f32,
b: u32 }
)

3 posts - 3 participants

Read full topic

🏷️ Rust_feed