-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
SocketAddr and friends now correctly pad its content #72398
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
The implementation here looks good to me. It's unclear to me though that we want to support padding in all of the various formatting impls; @rust-lang/libs, do we have a decision on that yet? (Both in the general sense and in the specific of these two impls). |
It makes sense that we wouldn't want it in general, but imo it's a bit surprising that "192.168.0.1" formats with padding but "192.168.0.1:8080" does not. I'd argue that it should at least be consistent within a "family" of types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me.
It is not a goal to support padding in all impls, but where someone needs it, it's fine to add. In the case of SocketAddr it's easy to imagine a program that wants to print a table with a socket addr column and uses the formatter paddings to align columns.
@bors r+ Approving in that case, I believe the code is correct. |
📌 Commit a126445bcdab83f04401b0e91f1df8dae31e07c6 has been approved by |
Failures here seem related to today's github outage |
…lacrum Various minor improvements to Ipv6Addr::Display Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to rust-lang#72399 and rust-lang#72398. - Defer to `Ipv4Addr::fmt` when printing an Ipv4 address - Fast path: write directly to `f` without an intermediary buffer when there are no alignment options - Simplify finding the inner zeroes-span
☔ The latest upstream changes (presumably #72716) made this pull request unmergeable. Please resolve the merge conflicts. |
IpAddr and friends pad when displaying; SocketAddr now does this as well
8c2a1fe
to
06a97a0
Compare
Fixed |
…lacrum Various minor improvements to Ipv6Addr::Display Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to rust-lang#72399 and rust-lang#72398. - Defer to `Ipv4Addr::fmt` when printing an Ipv4 address - Fast path: write directly to `f` without an intermediary buffer when there are no alignment options - Simplify finding the inner zeroes-span
@bors r=Mark-Simulacrum |
📌 Commit 06a97a0 has been approved by |
Rollup of 9 pull requests Successful merges: - rust-lang#72310 (Add Peekable::next_if) - rust-lang#72383 (Suggest using std::mem::drop function instead of explicit destructor call) - rust-lang#72398 (SocketAddr and friends now correctly pad its content) - rust-lang#72465 (Warn about unused captured variables) - rust-lang#72568 (Implement total_cmp for f32, f64) - rust-lang#72572 (Add some regression tests) - rust-lang#72591 (librustc_middle: Rename upvar_list to closure_captures) - rust-lang#72701 (Fix grammar in liballoc raw_vec) - rust-lang#72731 (Add missing empty line in E0619 explanation) Failed merges: r? @ghost
…lacrum Various minor improvements to Ipv6Addr::Display Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to rust-lang#72399 and rust-lang#72398. - Defer to `Ipv4Addr::fmt` when printing an Ipv4 address - Fast path: write directly to `f` without an intermediary buffer when there are no alignment options - Simplify finding the inner zeroes-span
Currently,
IpAddr
and friends correctly respect formatting parameters when printing viaDisplay
. This PR makes SocketAddr and friends do the same thing.