Skip to main content

callback

Macro callback 

Source
macro_rules! callback {
    ($(#[$m:meta])* $vis:vis fn $name:ident ($input:ident) $body:block) => { ... };
}
Expand description

Defines a #[proc_macro] callback that parses its Input and turns syn::Errors into compile errors. The body returns syn::Result<proc_macro2::TokenStream>.

ⓘ
announce::helper::callback! {
    /// Receives trait definitions.
    pub fn my_callback(input) {
        let entries = match input.gather(needed(&input)?) {
            announce::helper::Gather::Ready(e) => e,
            announce::helper::Gather::Fetch(ts) => return Ok(ts),
        };
        generate(entries)
    }
}

The facade crate must re-export the callback (e.g. under __private) so that generated code can name it.