Skip to content
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

Use dbg! instead of println! for simple debug prints #2478

Open
mgeisler opened this issue Nov 28, 2024 · 1 comment · May be fixed by #2676
Open

Use dbg! instead of println! for simple debug prints #2478

mgeisler opened this issue Nov 28, 2024 · 1 comment · May be fixed by #2676
Labels
good first issue Good for newcomers

Comments

@mgeisler
Copy link
Collaborator

Originally, we did not show stderr output from the Playground programs. This was fixed in #2397 and so we can finally start converting the trivial debug print statements to use dbg!.

Specifically, I'm thinking of the many print statements that look like this:

println!("a: {a:?}");

They can simply become

dbg!(a);

When doing this conversion, pay attention to any <!-- i18n:skip --> lines before the code block. They were added to skip translation of the "a: {a:?}" string, but now that the string disappears, the skip directive should be cleaned up too.

@mgeisler mgeisler added the good first issue Good for newcomers label Dec 11, 2024
mgeisler pushed a commit that referenced this issue Jan 15, 2025
Reverts #2383

Since #2397 is merged, to align the goal in #2478, rollback this temp
workaround.
@egithinji
Copy link
Contributor

Hi @mgeisler , I can look into this.

egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 21, 2025
@djmitche djmitche linked a pull request Feb 21, 2025 that will close this issue
djmitche added a commit to djmitche/comprehensive-rust that referenced this issue Feb 21, 2025
The `dbg!` macro, being deployed more widely in google#2478, shows the line
number. But if we inject `#![allow(..)]\n` then the printed numbers do
not match those in the textarea. It turns out that `\n` is not required!
djmitche added a commit that referenced this issue Feb 21, 2025
The `dbg!` macro, being deployed more widely in #2478, shows the line
number. But if we inject `#![allow(..)]\n` then the printed numbers do
not match those in the textarea. It turns out that `\n` is not required!

cc @egithinji
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 22, 2025
Part of google#2478 to clean up code blocks when all that is needed is a
trivial debug print statement.

In certain slides (8.1, 9.2, 9.3, 10.5) I've opted to retain the use of
println! because dbg! makes it less readable. The
dbg! macro uses pretty-printing by default and this results in a simple array such as the one in 8.1
being printed vertically instead of in one line.
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 22, 2025
Part of google#2478 to clean up code blocks when all that is needed is a
trivial debug print statement.

In certain slides (8.1, 9.2, 9.3, 10.5) I've opted to retain the use of
println! because dbg! makes it less readable. The
dbg! macro uses pretty-printing by default and this results in a simple array such as the one in 8.1
being printed vertically instead of a cleaner one-liner.
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 22, 2025
Part of google#2478 to clean up code blocks when all that is needed is a trivial debug print statement.
As in the other related PRs, in some places I opted to stick to println! for better
readability.
djmitche pushed a commit that referenced this issue Feb 24, 2025
As mentioned in #2478, this cleans up the code blocks when all that is
needed is a trivial debug print statement.
Only making changes to Day 1 morning session so that I can get feedback
before proceeding with the rest of the course.

---------

Co-authored-by: Eric Githinji <[email protected]>
djmitche pushed a commit that referenced this issue Feb 24, 2025
Part of #2478 to clean up code blocks when all that is needed is a
trivial debug print statement.

In certain slides (8.1, 9.2, 9.3, 10.5) I've opted to retain the use of
println! because dbg! makes it less readable. The
dbg! macro uses pretty-printing by default and this results in a simple
array such as the one in 8.1 being printed vertically instead of a
cleaner one-liner.

Co-authored-by: Eric Githinji <[email protected]>
egithinji added a commit to egithinji/comprehensive-rust that referenced this issue Feb 25, 2025
As mentioned in google#2478, this cleans up the code blocks when all that is
needed is a trivial debug print statement.
Only making changes to Day 1 morning session so that I can get feedback
before proceeding with the rest of the course.

---------

Co-authored-by: Eric Githinji <[email protected]>
egithinji added a commit to egithinji/comprehensive-rust that referenced this issue Feb 25, 2025
Part of google#2478 to clean up code blocks when all that is needed is a
trivial debug print statement.

In certain slides (8.1, 9.2, 9.3, 10.5) I've opted to retain the use of
println! because dbg! makes it less readable. The
dbg! macro uses pretty-printing by default and this results in a simple
array such as the one in 8.1 being printed vertically instead of a
cleaner one-liner.

Co-authored-by: Eric Githinji <[email protected]>
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 25, 2025
Part of google#2478 to clean up code blocks when all that is needed is a trivial debug print statement.
As in the other related PRs, in some places I opted to stick to println! for better
readability.
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 25, 2025
Part of google#2478 to clean up code blocks when all that is needed is a trivial debug print statement.

As mentioned in previous related PRs, in some places I've opted to retain the use of println! because dbg! makes it less readable.
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 25, 2025
Part of google#2478 to clean up code blocks when all that is needed is a trivial debug print statement.

As mentioned in previous related PRs, in some places I've opted to retain the use of println! because dbg! makes it less readable.
djmitche pushed a commit that referenced this issue Feb 25, 2025
Part of #2478 to clean up code blocks when all that is needed is a
trivial debug print statement.

As mentioned in previous related PRs, in some places I've opted to
retain the use of println! because dbg! makes it less readable.

Co-authored-by: Eric Githinji <[email protected]>
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 27, 2025
Part of google#2478 to clean up code blocks when all that is needed is a trivial debug print statement.
djmitche pushed a commit that referenced this issue Feb 27, 2025
Part of #2478 to clean up code blocks when all that is needed is a
trivial debug print statement.

Co-authored-by: Eric Githinji <[email protected]>
egithinji pushed a commit to egithinji/comprehensive-rust that referenced this issue Feb 28, 2025
Part of google#2478 to clean up code blocks when all that is needed is a trivial debug print statement.
The deep dive sessions didn't have that many occurrences of trivial println!
statements.

I believe this can close google#2478.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants