以下の内容はhttps://r9.hateblo.jp/entry/2022/06/09/224832より取得しました。


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 }



以上の内容はhttps://r9.hateblo.jp/entry/2022/06/09/224832より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14