-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement and forward more formatting traits for slices and arrays #46215
Conversation
For example: ```rust impl<T: Octal> Octal for [T; 5] { /* … */ } ``` This is mostly useful for showing binary (non-text) data in hexadecimal.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @TimNN (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
CC @rust-lang/libs I’ve added |
I believe the libs team discussed this in a PR or RFC a couple months ago and decided against adding these impls. I will try to find the discussion. |
"Added additional formatting options for slices" #44751 |
That feels very “perfect is the enemy of good” :( |
Later in the same comment,
Which is to say experience is the enemy of blind speculation. The design space here is wide enough that we would benefit from lots of experience with this in library form, rather than guessing what people want based on a few people using this while it is only usable on nightly. |
At least as far as I’m concerned, I’ve wanted this in two kinds of cases: for “printf-debugging” with temporary So what is (in my opinion) lacking here is the opposite of an entire library that supports all kinds of combinations, it is “ Perhaps a better solution would be a (pair of) flags for (By the way, I hadn’t really managed to find how to express it before, but I’ve always felt like the |
It does work on integers, not on slices. I think this is due to not using the original Edit: #46233 should fix this. |
This is PR is unlikely to succeed as-is since pretty much the same was rejected before. Closing in favor of rust-lang/rfcs#2226. |
For example:
This is mostly useful for showing binary (non-text) data in hexadecimal.