Skip to content

Commit 523701a

Browse files
committed
auto merge of #8942 : novalis/rust/fmt, r=alexcrichton
2 parents 3830738 + 5977376 commit 523701a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/libstd/fmt/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ For integral types, this has no meaning currently.
308308
For floating-point types, this indicates how many digits after the decimal point
309309
should 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

313320
use prelude::*;

src/test/run-pass/ifmt.rs

+6
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ pub fn main() {
213213
t!(format!("{:+10.3f}", 1.0f), " +1.000");
214214
t!(format!("{:+10.3f}", -1.0f), " -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

0 commit comments

Comments
 (0)