Test and document escaping on format!()
This commit is contained in:
parent
3c4e943881
commit
5977376b46
@ -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::*;
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user