An identifier fragment specifier, written as `ident`, matches an identifier token supplied to a Rust declarative macro. It is useful when a macro needs a type, struct, or other named item while generating the remaining code itself. section 2.2.3
Generating a newtype method
The `generate_get_value` macro captures a struct name with `$struct_type:ident`, inserts that name into an `impl` block, and generates `get_value`. Calls such as `generate_get_value!(FirstName);` and `generate_get_value!(LastName);` reuse the same implementation pattern. section 2.2.3
The matcher captures only the item name; the generated method, return type, and field access remain fixed unless additional fragments are accepted. A second matcher can capture a return type with `ty`, allowing the same macro to support both `String` and `i32` newtypes. section 2.2.3
macro_rules! ??? {
??? => {
impl $something {
fn hello_world(&self) {
println!("Hello world")
}
}
};
}
struct Example {}
hello_world!(Example);
fn main() {
let e = Example {};
e.hello_world(); // prints "Hello world"
}
Complete the matcher and transcriber so a macro accepts an identifier such as `Example` and generates its `hello_world` method. section 2.4

