Rust で { と } を表示する
error: invalid format string: expected `'}'`, found `'{'`
{ hoge } という文字列を println! しようとしたら、エラーになった。
let s = "hoge"; println!("{ {} }", s);
error: invalid format string: expected `'}'`, found `'{'` --> src\main.rs:316:21 | 316 | println!("{ {} }", s); | - ^ expected `}` in format string | | | because of this opening brace | = note: if you intended to print `{`, you can escape it using `{{`
コンパイラが教えてくれたとおり、{{ と }} を使えば OK。
他の言語だとバックスラッシュとかかなと思ったけど違った。
println!("{{ {} }}", s);
{ hoge }