You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-06-28 03:28:32 +02:00
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 <egithinji@google.com>
This commit is contained in:
@ -19,11 +19,11 @@ match ANCHOR comments in the `exercise.rs` file. Each segment also has a
|
|||||||
`Cargo.toml`. The result is that `exercise.rs` is built and tested by
|
`Cargo.toml`. The result is that `exercise.rs` is built and tested by
|
||||||
`cargo test`.
|
`cargo test`.
|
||||||
|
|
||||||
For segments on day 1, exercises should use `fn main() { .. }` and `println!`,
|
For segments on day 1, exercises should use `fn main() { .. }` and `dbg!` or
|
||||||
with students visually verifying the correct output. On subsequent days, prefer
|
`println!`, with students visually verifying the correct output. On subsequent
|
||||||
tests and omit `fn main() { .. }`. However, where tests would be difficult and
|
days, prefer tests and omit `fn main() { .. }`. However, where tests would be
|
||||||
visual verification is more natural (such as in the Logger exercise), using
|
difficult and visual verification is more natural (such as in the Logger
|
||||||
`fn main { .. }` is OK.
|
exercise), using `fn main { .. }` is OK.
|
||||||
|
|
||||||
Especially for exercises without tests, consider including tests in
|
Especially for exercises without tests, consider including tests in
|
||||||
`exercise.rs` that do not appear in either `exercise.md` or `solution.md`, as
|
`exercise.rs` that do not appear in either `exercise.md` or `solution.md`, as
|
||||||
|
@ -15,9 +15,9 @@ use spin::mutex::SpinMutex;
|
|||||||
static COUNTER: SpinMutex<u32> = SpinMutex::new(0);
|
static COUNTER: SpinMutex<u32> = SpinMutex::new(0);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("count: {}", COUNTER.lock());
|
dbg!(COUNTER.lock());
|
||||||
*COUNTER.lock() += 2;
|
*COUNTER.lock() += 2;
|
||||||
println!("count: {}", COUNTER.lock());
|
dbg!(COUNTER.lock());
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use std::thread;
|
|||||||
fn foo() {
|
fn foo() {
|
||||||
let s = String::from("Hello");
|
let s = String::from("Hello");
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
println!("Length: {}", s.len());
|
dbg!(s.len());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ fn foo() {
|
|||||||
let s = String::from("Hello");
|
let s = String::from("Hello");
|
||||||
thread::scope(|scope| {
|
thread::scope(|scope| {
|
||||||
scope.spawn(|| {
|
scope.spawn(|| {
|
||||||
println!("Length: {}", s.len());
|
dbg!(s.len());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user