about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libstd/fmt/mod.rs7
-rw-r--r--src/test/run-pass/ifmt.rs6
2 files changed, 13 insertions, 0 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index da5abe95787..8d50f5efa48 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -308,6 +308,13 @@ For integral types, this has no meaning currently.
 For floating-point types, this indicates how many digits after the decimal point
 should be printed.
 
+## Escaping
+
+The literal characters `{`, `}`, or `#` may be included in a string by
+preceding them with the `\` character. Since `\` is already an
+escape character in Rust strings, a string literal using this escape
+will look like `"\\{"`.
+
 */
 
 use prelude::*;
diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs
index 236fa44939a..8ed93a13d60 100644
--- a/src/test/run-pass/ifmt.rs
+++ b/src/test/run-pass/ifmt.rs
@@ -213,6 +213,12 @@ pub fn main() {
     t!(format!("{:+10.3f}", 1.0f),  "    +1.000");
     t!(format!("{:+10.3f}", -1.0f), "    -1.000");
 
+    // Escaping
+    t!(format!("\\{"), "{");
+    t!(format!("\\}"), "}");
+    t!(format!("\\#"), "#");
+    t!(format!("\\\\"), "\\");
+
     test_write();
     test_print();