Macro mini_macro_magic::example::demo_struct
source · macro_rules! demo_struct { ($($t:tt)*) => { ... }; }
Expand description
This is the macro generated by the example.
Injects the exported tokens (see section below) into the given macro call.
The exported tokens are injected in a {}
block as the first thing.
For example with some_macro!(a + b)
the actual macro call would look like
some_macro!({ ... <exported tokens> ... } a + b)
.
Expand to show exported tokens
Note: The tokens here are formatted via stringify!()
so may not be very
readable.
#[doc = r" Demo struct definition."] pub struct Demo
{
#[doc = r" The X value."] pub x: i32, #[doc = r" The Y value."] pub y:
i32,
}
Examples
use mini_macro_magic::example::demo_struct;
// Stringify all the exported tokens. The exported tokens are passed as a `{}`
// block to `stringify!()` at the beginning.
let as_string = demo_struct!(stringify!(some extra tokens));
// Check that it matches what we expect.
assert_eq!(as_string, r#####"{
#[doc = r" Demo struct definition."] pub struct Demo
{
#[doc = r" The X value."] pub x: i32, #[doc = r" The Y value."] pub y:
i32,
}
} some extra tokens"#####);