You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During tutorial, a student wanted to print out a { in the std output.
Their intuitive way of doing this yielded a non-ideal error message:
fnmain(){println!("{");}
Error message:
error: invalid format string: expected `'}'` but string was terminated
--> <std macros>:1:33
1 |> ( $ fmt : expr ) => ( print ! ( concat ! ( $ fmt , "\n" ) ) ) ; (
|> ^^^^^^^^^^^^^^^^^^^^^^^^^
<std macros>:1:33: 1:58: note: in this expansion of concat!
<std macros>:1:33: 1:58: note: in this expansion of format_args!
<std macros>:1:33: 1:58: note: in this expansion of print! (defined in <std macros>)
<std macros>:1:33: 1:58: note: in this expansion of println! (defined in <std macros>)
error: aborting due to previous error
The student knew that they wanted some kind of escape sequence, but did not know what to use (e.g. they tried e.g. \{, which does not work).
Ideally we would include a HELP output that would suggest that if an output { were desired, then one should instead write {{.
The text was updated successfully, but these errors were encountered:
…chton
On fmt string with unescaped `{` note how to escape
On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char.
Fixrust-lang#34300.
eddyb
added a commit
to eddyb/rust
that referenced
this issue
Nov 12, 2016
…chton
On fmt string with unescaped `{` note how to escape
On cases of malformed format strings where a `{` hasn't been properly escaped, like `println!("{");`, present a NOTE explaining how to escape the `{` char.
Fixrust-lang#34300.
During tutorial, a student wanted to print out a
{
in the std output.Their intuitive way of doing this yielded a non-ideal error message:
Error message:
The student knew that they wanted some kind of escape sequence, but did not know what to use (e.g. they tried e.g.
\{
, which does not work).Ideally we would include a HELP output that would suggest that if an output
{
were desired, then one should instead write{{
.The text was updated successfully, but these errors were encountered: