//! format!("{value}", value=4); // => "4"
//! format!("{} {}", 1, 2); // => "1 2"
//! format!("{:04}", 42); // => "0042" with leading zeros
+//! format!("{:#?}", (100, 200)); // => "(
+//! // 100,
+//! // 200,
+//! // )"
//! ```
//!
//! From these, you can see that the first argument is a format string. It is
//!
//! * `+` - This is intended for numeric types and indicates that the sign
//! should always be printed. Positive signs are never printed by
- //! default, and the negative sign is only printed by default for the
- //! `Signed` trait. This flag indicates that the correct sign (`+` or `-`)
- //! should always be printed.
+ //! default, and the negative sign is only printed by default for signed values.
+ //! This flag indicates that the correct sign (`+` or `-`) should always be printed.
//! * `-` - Currently not used
//! * `#` - This flag indicates that the "alternate" form of printing should
//! be used. The alternate forms are:
-//! * `#?` - pretty-print the [`Debug`] formatting
+//! * `#?` - pretty-print the [`Debug`] formatting (adds linebreaks and indentation)
//! * `#x` - precedes the argument with a `0x`
//! * `#X` - precedes the argument with a `0x`
//! * `#b` - precedes the argument with a `0b`
t!(format!("{:?}", 10_usize), "10");
t!(format!("{:?}", "true"), "\"true\"");
t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\"");
- t!(
- format!("{:?}", "foo\n\"bar\"\r\n\'baz\'\t\\qux\\"),
- r#""foo\n\"bar\"\r\n\'baz\'\t\\qux\\""#
- );
+ t!(format!("{:?}", "foo\n\"bar\"\r\n\'baz\'\t\\qux\\"), r#""foo\n\"bar\"\r\n'baz'\t\\qux\\""#);
t!(format!("{:?}", "foo\0bar\x01baz\u{7f}q\u{75}x"), r#""foo\u{0}bar\u{1}baz\u{7f}qux""#);
t!(format!("{:o}", 10_usize), "12");
t!(format!("{:x}", 10_usize), "a");
t!(format!("{:+10.3e}", -1.2345e6f64), " -1.234e6");
// Float edge cases
- t!(format!("{}", -0.0), "0");
- t!(format!("{:?}", -0.0), "-0.0");
+ t!(format!("{}", -0.0), "-0");
t!(format!("{:?}", 0.0), "0.0");
// sign aware zero padding