std-type

fmt::Arguments: borrowed formatting plan

Pass a formatting plan into a helper for immediate consumption. It can borrow temporary values and generally should not be saved for later use. Expected stdout (not executed): INFO count=4 Common mistake: Storing format_args! with placeholders and assuming it owns the arguments.

Formal Syntax & Structure

rust syntaxrust
fmt::Arguments<'_>; format_args!(...)

Working Example

Example Snippetrust
fn main() {    fn log(args: std::fmt::Arguments<'_>) { println!("INFO {args}"); }    let count = 4;    log(format_args!("count={count}"));}
Rust Reference