-
Notifications
You must be signed in to change notification settings - Fork 13.3k
core: fmt: debug builders pretty print tuple structs and enum variants in a single line #26874
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
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
r? @sfackler |
The current behavior is intentional, as described in the RFC: rust-lang/rfcs#640. The pretty printing mode is designed for ease of readability, not matching rust style. Printing some things in one line and others in multiples does not nest well: MyTupleStruct(MyStruct {
a: 1,
b: TupleStruct(MyOtherStruct {
foo: bar
}, 10, "hi", Thing {
baz: buzz
})
}, true, false, OtherStruct {
thing: "hi"
}) It could potentially be nice to print single-variant tuples in one line if there are no line breaks in the output for the inner value, but I'm not sure how that would work. |
OK, maybe an RFC is required to propose changing this a bit?
But I do think that
Tuples with nested struct, already pretty print in a single line, and this PR doesn't change that. http://is.gd/ZJKuVy |
The tuple behavior is a bug, not a feature. |
So, let's resolve it through an RFC
|
I've written an RFC rust-lang/rfcs#1198 |
☔ The latest upstream changes (presumably #26913) made this pull request unmergeable. Please resolve the merge conflicts. |
The associated RFC was closed, so I'm going to close this as well. |
Before this PR,
println!("{:#?}", Some(1));
pretty prints debug output as:(by adding newlines and indent)
But I don't think it's pretty print: it's weird, even not a preferred code style.
Some(1)
itself (without newlines and indent) is pretty print, IMO.This PR change the pretty print output, to print tuple structs and enum variants in a single line. (We already pretty print tuples in this way.)
Perhaps this is a [breaking-change]? And an RFC is required? I don't known.