diff options
| author | Piotr Jawniak <sawyer47@gmail.com> | 2017-03-03 15:42:30 +0100 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-03-15 07:50:44 -0700 |
| commit | ff63866edb511a73eed657a8a4f5c81f1ee5a9bb (patch) | |
| tree | a9f4fdcbba4d05220796bcc46a2a1dda5f76a90f /src/libcollections | |
| parent | 6f10e2f63de720468e2b4bfcb275e4b90b1f9870 (diff) | |
Change how the `0` flag works in format!
Now it always implies right-alignment, so that padding zeroes are placed after the sign (if any) and before the digits. In other words, it always takes precedence over explicitly specified `[[fill]align]`. This also affects the '#' flag: zeroes are placed after the prefix (0b, 0o, 0x) and before the digits.
:05 :<05 :>05 :^05
before |-0001| |-1000| |-0001| |-0100|
after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
before |0x001| |0x100| |000x1| |0x010|
after |0x001| |0x001| |0x001| |0x001|
Fixes #39997 [breaking-change]
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/fmt.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index dfd292176d2..2735293528e 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -366,6 +366,10 @@ //! like `{:08}` would yield `00000001` for the integer `1`, while the //! same format would yield `-0000001` for the integer `-1`. Notice that //! the negative version has one fewer zero than the positive version. +//! Note that padding zeroes are always placed after the sign (if any) +//! and before the digits. When used together with the `#` flag, a similar +//! rule applies: padding zeroes are inserted after the prefix but before +//! the digits. //! //! ## Width //! |
