expression

Escape literal braces

Double a brace inside a format literal to emit it as text; this is formatting syntax, not string escaping. Expected stdout (not executed): {count: 5} Common mistake: Using backslashes to escape braces inside the format grammar.

Formal Syntax & Structure

rust syntaxrust
{{ and }}

Working Example

Example Snippetrust
fn main() {    let n=5;    println!("{{count: {n}}}");}
Rust Reference