expression
Named and positional formatting arguments
Explicit indices and named arguments make the intended correspondence clear. Captured identifiers can be used directly in the format string. Expected stdout (not executed): mass: 3 kg Common mistake: Assuming explicit positional indexes advance the implicit argument cursor.
Formal Syntax & Structure
rust syntaxrust
{name}; {0}; {}Working Example
Example Snippetrust
fn main() { let unit="kg"; println!("{1} {0} {unit}", 3, "mass:");}