Test and document escaping on format!()

This commit is contained in:
novalis 2013-09-03 00:38:46 -04:00
parent 3c4e943881
commit 5977376b46
2 changed files with 13 additions and 0 deletions

View File

@ -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::*;

View File

@ -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();