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:
fn main() {
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 {{.
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{{.