1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-07-05 06:00:30 +02:00

Use dbg! instead of println! in Day 2. (#2657)

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 <egithinji@google.com>
This commit is contained in:
Eric Githinji
2025-02-26 00:12:06 +03:00
committed by GitHub
parent 32a8b4bf13
commit 1a64c9ba9a
6 changed files with 12 additions and 13 deletions

View File

@ -4,13 +4,11 @@ Like with `if let`, there is a
[`while let`](https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops)
variant which repeatedly tests a value against a pattern:
<!-- mdbook-xgettext: skip -->
```rust,editable
fn main() {
let mut name = String::from("Comprehensive Rust 🦀");
while let Some(c) = name.pop() {
println!("character: {c}");
dbg!(c);
}
// (There are more efficient ways to reverse a string!)
}