Skip to main content

paste

Macro paste 

Source
paste!() { /* proc-macro */ }
Expand description

Concatenates the tokens inside each {{ ... }} marker into a single identifier at compile time, passing all other tokens through unchanged.

Use it to mint identifier names in declaration position — something the runtime [moxy::token::ident!] macro cannot do. Segments are taken by token text (not evaluated), then validated as a Rust identifier.

§Example

ⓘ
paste! {
    fn {{ get_ value }}() -> u32 { 7 }   // expands to: fn get_value() -> u32 { 7 }
}
assert_eq!(get_value(), 7);

A {{ ... }} that does not concatenate to a valid identifier produces a span-targeted compile error.