about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-03 20:56:19 -0700
committerbors <bors@rust-lang.org>2013-09-03 20:56:19 -0700
commit523701aad00570b1f1632df25673872ffd9be7e8 (patch)
treee09fec43824133dfcf681959096a0d72d5e5d62d
parent383073883f1f07af0088b58d20e55e28c4942a64 (diff)
parent5977376b4615f5efe590ee7775c48d82211c68ab (diff)
downloadrust-523701aad00570b1f1632df25673872ffd9be7e8.tar.gz
rust-523701aad00570b1f1632df25673872ffd9be7e8.zip
auto merge of #8942 : novalis/rust/fmt, r=alexcrichton
-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();