-
Notifications
You must be signed in to change notification settings - Fork 13.3k
want version of dbg! using {:?} not {:#?} #82778
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
Comments
@rustbot modify labels +C-feature-request +T-libs |
Another bikeshed possibility is to have an alternate pattern added to |
If someone wanted to try this out as a package first, I'd personally use it. |
@ijackson wrote:
It tends to depend on the nature of the output you have. When printing a complex structure, especially a nested structure, the It might be worth considering improvements to the All that said, we have both formats for a reason, and it's not unreasonable to want access to both. The question then becomes, how often do people want a It's also worth noting that we could provide a macro with a less-abbreviated name, and people who want a more abbreviated version could @cuviper I personally don't think it'd be a good idea to add a semi-magic argument to the `dbg! macro to change the output format.
This seems reasonable, and I'd be happy to r+ a PR adding such a note to the documentation. |
…iplett dbg macro: Discuss use in tests, and slightly clarify As discussed in a tangent in rust-lang#82778. I chose to use [semantic newlines](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) in the source text but I don't mind reformatting it.
…iplett dbg macro: Discuss use in tests, and slightly clarify As discussed in a tangent in rust-lang#82778. I chose to use [semantic newlines](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) in the source text but I don't mind reformatting it.
…iplett dbg macro: Discuss use in tests, and slightly clarify As discussed in a tangent in rust-lang#82778. I chose to use [semantic newlines](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) in the source text but I don't mind reformatting it.
I'm looking to implement this, and I personally think Also - am I good to claim? |
Closing this as it is better suited to be trialed as a crate (there are a few present already now but weren't around at the time this issue was created). |
Since the same feature has been added to gstd (gear-tech/gear#3610) this crate should've been deprecated However, the compact version of dbg! proposed in rust-lang/rust#82778 does look better So let me repurpose this crate as the compact implementation of dbg! for gear smart contracts
I find the pretty-printing output from
dbg!
more annoying than helpful and I am privately using a version of this macro that doesn't pretty-print.When I discussed this on the Discord several people also shared the same opinion about
dbg!
's pretty-printing. (No-one really said they liked it, although that's a biased sample...) This suggests that there would be demand for a compact output version in std. While the docs forstd::dbg!
say the output format cannot be relied on, ISTM that changing it to remove the#
would be rude (and controversial). So I suggest providing a compact version in parallel. I suggest the namedbgc!
for "debug compact" but I am of course happy with whatever colour bikeshed.If the libs team thinks this would be welcome, I will make an MR for it. If the libs team don't like this idea then fine, I can keep using my clone-and-hack :-).
While I'm here I notice that the docs suggest committing calls to
dbg!
is a bad idea. grepping my own codebase showed that I agree with one significant exception: I use it liberally in tests. I think it's great there and the docs could probably mention that as a good use case.The text was updated successfully, but these errors were encountered: