Skip to content

Change how the 0 flag works in format! - #40241

Merged
bors merged 2 commits into
rust-lang:masterfrom
Sawyer47:fix-39997
Mar 20, 2017
Merged

Change how the 0 flag works in format!#40241
bors merged 2 commits into
rust-lang:masterfrom
Sawyer47:fix-39997

Conversation

@Sawyer47

Copy link
Copy Markdown
Contributor

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.

Here's a short summary of how similar format strings work in Python and Rust:

 :05 :<05 :>05 :^05 Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001| :#05x :<#05x :>#05x :^#05x Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001| 

Fixes#39997 [breaking-change]

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@Sawyer47

Copy link
Copy Markdown
ContributorAuthor

Please don't merge it yet as I completely forgot about floats. I was slightly misled by the current documentation of 0 flag, because it only says about integer formats.

@Sawyer47

Copy link
Copy Markdown
ContributorAuthor

I updated the logic for floats as well.

@alexcrichtonalexcrichton added the T-libs-api [DEPRECATED; DO NOT USE] label Mar 6, 2017
@alexcrichton

Copy link
Copy Markdown
Member

Thanks for the PR @Sawyer47! I've tagged this with T-libs to ensure that it comes up during triage which is where we'll discuss the breakage aspect

@alexcrichton

Copy link
Copy Markdown
Member

@rust-lang/libs if you've got opinions ahead of time, feel free to comment here!

I'm fine landing this PR personally.

@alexcrichton

Copy link
Copy Markdown
Member

Discussed during libs triage today the conclusion was that athis is good to go. Thanks for the PR @Sawyer47!

@bors: r+

@bors

bors commented Mar 14, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 6652cef has been approved by alexcrichton

@bors

bors commented Mar 15, 2017

Copy link
Copy Markdown
Collaborator

🔒 Merge conflict

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|
Fixesrust-lang#39997 [breaking-change]
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]`.
:06 :<06 :>06 :^06
before |-001.2| |-1.200| |-001.2| |-01.20|
after |-001.2| |-001.2| |-001.2| |-001.2|
@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented Mar 15, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 8065486 has been approved by alexcrichton

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 18, 2017
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.
Here's a short summary of how similar format strings work in Python and Rust:
```
:05 :<05 :>05 :^05
Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001|
```
Fixesrust-lang#39997 [breaking-change]
@frewsxcvfrewsxcv mentioned this pull request Mar 18, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 18, 2017
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.
Here's a short summary of how similar format strings work in Python and Rust:
```
:05 :<05 :>05 :^05
Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001|
```
Fixesrust-lang#39997 [breaking-change]
@arielb1arielb1 mentioned this pull request Mar 18, 2017
bors added a commit that referenced this pull request Mar 18, 2017
@arielb1arielb1 mentioned this pull request Mar 19, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 19, 2017
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.
Here's a short summary of how similar format strings work in Python and Rust:
```
:05 :<05 :>05 :^05
Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001|
```
Fixesrust-lang#39997 [breaking-change]
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 19, 2017
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.
Here's a short summary of how similar format strings work in Python and Rust:
```
:05 :<05 :>05 :^05
Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001|
```
Fixesrust-lang#39997 [breaking-change]
@frewsxcvfrewsxcv mentioned this pull request Mar 19, 2017
@bors

bors commented Mar 19, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8065486 with merge bd14bc3...

@bors

bors commented Mar 19, 2017

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@alexcrichton

alexcrichton commented Mar 19, 2017 via email

Copy link
Copy Markdown
Member

@frewsxcvfrewsxcv mentioned this pull request Mar 19, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 20, 2017
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.
Here's a short summary of how similar format strings work in Python and Rust:
```
:05 :<05 :>05 :^05
Python 3.6 |-0001| |-1000| |000-1| |0-100|
Rust before |-0001| |-1000| |-0001| |-0100|
Rust after |-0001| |-0001| |-0001| |-0001|
:#05x :<#05x :>#05x :^#05x
Python 3.6 |0x001| |0x100| |000x1| |00x10|
Rust before |0x001| |0x100| |000x1| |0x010|
Rust after |0x001| |0x001| |0x001| |0x001|
```
Fixesrust-lang#39997 [breaking-change]
@frewsxcvfrewsxcv mentioned this pull request Mar 20, 2017
@bors

bors commented Mar 20, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8065486 with merge 9902af4...

@bors

bors commented Mar 20, 2017

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-appveyor

bors added a commit that referenced this pull request Mar 20, 2017
Rollup of 9 pull requests
- Successful merges: #40241, #40281, #40398, #40521, #40532, #40554, #40566, #40581, #40587
- Failed merges:
@bors
bors merged commit 8065486 into rust-lang:masterMar 20, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text formatting: a leading zero on the minimum width should really mean leading zero

5 participants

@Sawyer47@rust-highfive@alexcrichton@bors@sfackler