Expand description

Example of using export and emit.

This module is not part of the crate’s public API and is only visible on docs.

Code used for this module:

pub mod example {
    mini_macro_magic::export!(
        #[export(
            /// This is the macro generated by the example.
            pub demo_struct$
        )]
        {
            /// Demo struct definition.
            pub struct Demo {
                /// The X value.
                pub x: i32,

                /// The Y value.
                pub y: i32,
            }
        }
    );

    // Emit the struct definition for Demo.
    demo_struct!(mini_macro_magic::emit!());
}

Demo is a struct definition exported by export. As you can see it exists as expected as a normal struct because we emitted the tokens into the module with emit.

demo_struct is the macro that was generated by export. This is the macro you would call to inspect the tokens of Demo.

Macros

Structs

  • Demo struct definition.