#[attribute]Expand description
Defines an attribute macro entry point that auto-parses the annotated item into typed inputs.
Extractors marked #[zyn(input)] are resolved from the annotated item via
FromInput. An optional args: zyn::Args parameter receives
the raw attribute arguments. The macro name defaults to the function name.
§Examples
ⓘ
// In your proc-macro crate (lib.rs):
#[zyn::attribute]
fn log_call(
#[zyn(input)] item: syn::ItemFn,
args: zyn::Args,
) -> zyn::TokenStream {
let prefix = args.get("prefix")
.and_then(|a| a.value::<String>().ok())
.unwrap_or_else(|| "CALL".into());
zyn::zyn! {
{{ item }}
}
}
// Applied to a function:
#[log_call(prefix = "DEBUG")]
fn my_fn() { ... }With an explicit macro name:
ⓘ
#[zyn::attribute("trace")]
fn trace_impl(#[zyn(input)] item: syn::ItemFn) -> zyn::TokenStream { ... }
// Registers as #[trace]§Debugging
Add debug to inspect the generated code as a compiler note diagnostic.
Requires the ZYN_DEBUG environment variable to match the function name
(supports * wildcards).
ⓘ
#[zyn::attribute(debug)]
#[zyn::attribute(debug = "pretty")] // requires `pretty` featureWithout ZYN_DEBUG, the debug argument is inert — safe to leave in source.
See the debugging guide for details.