File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,13 @@ For integral types, this has no meaning currently.
308308For floating-point types, this indicates how many digits after the decimal point
309309should be printed.
310310
311+ ## Escaping
312+
313+ The literal characters `{`, `}`, or `#` may be included in a string by
314+ preceding them with the `\` character. Since `\` is already an
315+ escape character in Rust strings, a string literal using this escape
316+ will look like `"\\{"`.
317+
311318*/
312319
313320use prelude:: * ;
Original file line number Diff line number Diff line change @@ -213,6 +213,12 @@ pub fn main() {
213213 t!( format!( "{:+10.3f}" , 1.0 f) , " +1.000" ) ;
214214 t!( format!( "{:+10.3f}" , -1.0 f) , " -1.000" ) ;
215215
216+ // Escaping
217+ t!( format!( "\\ {" ) , "{" ) ;
218+ t!( format!( "\\ }" ) , "}" ) ;
219+ t!( format!( "\\ #" ) , "#" ) ;
220+ t!( format!( "\\ \\ " ) , "\\ " ) ;
221+
216222 test_write( ) ;
217223 test_print( ) ;
218224
You can’t perform that action at this time.
0 commit comments