Proc Macro Entry Points
zyn provides attribute macros that replace #[proc_macro_derive] and #[proc_macro_attribute] with a declarative, template-first workflow.
#[zyn::derive]— replaces#[proc_macro_derive]#[zyn::attribute]— replaces#[proc_macro_attribute]
What’s Generated
Both macros generate a complete proc macro entry point:
- Input parsing —
DeriveInputfor derives,Itemfor attributes, wrapped inzyn::Input inputbinding — available in scope forzyn!and element extractors- Extractor resolution —
#[zyn(input)]parameters are resolved viaFromInput - Diagnostic macros —
error!,warn!,note!,help!,bail!(same as#[zyn::element]) - Return type conversion — your
proc_macro2::TokenStreamis automatically converted toproc_macro::TokenStream
You write a function that returns zyn::TokenStream. The macro handles everything else.