std-function

fmt::format: materialize arguments

Use this function to produce an owned String from arguments, for example when a helper accepts format_args!. Expected stdout (not executed): id=9 Common mistake: Assuming the result borrows the original argument.

Formal Syntax & Structure

rust syntaxrust
std::fmt::format(args: fmt::Arguments<'_>) -> String

Working Example

Example Snippetrust
fn main() {    fn render(args: std::fmt::Arguments<'_>) -> String { std::fmt::format(args) }    let s = render(format_args!("id={}", 9));    println!("{s}");}
Rust Reference