Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Docs: fix incorrect copy-paste for new X? in formatting strings #49161

Merged
merged 1 commit into from
Mar 20, 2018

Conversation

SimonSapin
Copy link
Contributor

No description provided.

SimonSapin referenced this pull request Mar 19, 2018
Add hexadecimal formatting of integers with fmt::Debug

This can be used for integers within a larger types which implements Debug (possibly through derive) but not fmt::UpperHex or fmt::LowerHex.

```rust
assert!(format!("{:02x?}", b"Foo\0") == "[46, 6f, 6f, 00]");
assert!(format!("{:02X?}", b"Foo\0") == "[46, 6F, 6F, 00]");
```

RFC: rust-lang/rfcs#2226

The new formatting string syntax (`x?` and `X?`) is insta-stable in this PR because I don’t know how to change a built-in proc macro’s behavior based of a feature gate. I can look into adding that, but I also strongly suspect that keeping this feature unstable for a time period would not be useful as possibly no-one would use it during that time.

This PR does not add the new (public) `fmt::Formatter` proposed in the API because:

* There was some skepticism on response to this part of the RFC
* It is not possible to implement as-is without larger changes to `fmt`, because `Formatter` at the moment has no easy way to tell apart for example `Octal` from `Binary`: it only has a function pointer for the relevant `fmt()` method.

If some integer-like type outside of `std` want to implement this behavior, another RFC will likely need to propose a different public API for `Formatter`.
@SimonSapin SimonSapin added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Mar 19, 2018
@KodrAus
Copy link
Contributor

KodrAus commented Mar 19, 2018

D'oh! The most obvious things are always the hardest to see.

@bors r+

@bors
Copy link
Contributor

bors commented Mar 19, 2018

📌 Commit 741d7a5 has been approved by KodrAus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 19, 2018
@varkor varkor mentioned this pull request Mar 19, 2018
@bors
Copy link
Contributor

bors commented Mar 19, 2018

⌛ Testing commit 741d7a5 with merge 02e297165031c3a7eebc4eca4282cd4da810bc93...

@pietroalbini
Copy link
Member

Wut, both Travis and AppVeyor failed to clone the repository, and bors didn't update.

@bors retry rollup

@bors
Copy link
Contributor

bors commented Mar 19, 2018

@pietroalbini: 🔑 Insufficient privileges: Not in reviewers

@alexcrichton
Copy link
Member

@bors: retry

bors is having a rough day...

kennytm added a commit to kennytm/rust that referenced this pull request Mar 20, 2018
…rAus

Docs: fix incorrect copy-paste for new `X?` in formatting strings
bors added a commit that referenced this pull request Mar 20, 2018
Rollup of 17 pull requests

- Successful merges: #46518, #48810, #48834, #48902, #49004, #49092, #49096, #49099, #49104, #49125, #49139, #49152, #49157, #49161, #49166, #49176, #49184
- Failed merges:
@bors bors merged commit 741d7a5 into master Mar 20, 2018
@alexcrichton alexcrichton deleted the SimonSapin-patch-1 branch March 23, 2018 14:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants