Skip to content

Commit a2ad59e

Browse files
egithinjiEric Githinji
andauthored
Use dbg! instead of println! in deep dive sessions. (#2676)
Part of #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 #2478. Co-authored-by: Eric Githinji <[email protected]>
1 parent 9d7ae61 commit a2ad59e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ match ANCHOR comments in the `exercise.rs` file. Each segment also has a
1919
`Cargo.toml`. The result is that `exercise.rs` is built and tested by
2020
`cargo test`.
2121

22-
For segments on day 1, exercises should use `fn main() { .. }` and `println!`,
23-
with students visually verifying the correct output. On subsequent days, prefer
24-
tests and omit `fn main() { .. }`. However, where tests would be difficult and
25-
visual verification is more natural (such as in the Logger exercise), using
26-
`fn main { .. }` is OK.
22+
For segments on day 1, exercises should use `fn main() { .. }` and `dbg!` or
23+
`println!`, with students visually verifying the correct output. On subsequent
24+
days, prefer tests and omit `fn main() { .. }`. However, where tests would be
25+
difficult and visual verification is more natural (such as in the Logger
26+
exercise), using `fn main { .. }` is OK.
2727

2828
Especially for exercises without tests, consider including tests in
2929
`exercise.rs` that do not appear in either `exercise.md` or `solution.md`, as

src/bare-metal/useful-crates/spin.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use spin::mutex::SpinMutex;
1515
static COUNTER: SpinMutex<u32> = SpinMutex::new(0);
1616
1717
fn main() {
18-
println!("count: {}", COUNTER.lock());
18+
dbg!(COUNTER.lock());
1919
*COUNTER.lock() += 2;
20-
println!("count: {}", COUNTER.lock());
20+
dbg!(COUNTER.lock());
2121
}
2222
```
2323

src/concurrency/threads/scoped.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::thread;
1212
fn foo() {
1313
let s = String::from("Hello");
1414
thread::spawn(|| {
15-
println!("Length: {}", s.len());
15+
dbg!(s.len());
1616
});
1717
}
1818
@@ -30,7 +30,7 @@ fn foo() {
3030
let s = String::from("Hello");
3131
thread::scope(|scope| {
3232
scope.spawn(|| {
33-
println!("Length: {}", s.len());
33+
dbg!(s.len());
3434
});
3535
});
3636
}

0 commit comments

Comments
 (0)