macro
stringify! — Turn source tokens into text without evaluation
Produce a static string representing the supplied tokens, without evaluating them or requiring a name to resolve as a value. The exact whitespace of more complex token sequences is not a stable serialization format. Expression result: &'static str. Expected result (not executed): stdout: 'Field: inventory_total\n'; no stderr. Common mistake: Expecting stringify!(variable) to print the variable's current value.
Formal Syntax & Structure
rust syntaxrust
stringify!(tokens...)Working Example
Example Snippetrust
fn main() { let label = stringify!(inventory_total); println!("Field: {label}");}