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! in deep dive sessions. #2676

Merged
merged 1 commit into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 test`.

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

Especially for exercises without tests, consider including tests in
`exercise.rs` that do not appear in either `exercise.md` or `solution.md`, as
Expand Down
4 changes: 2 additions & 2 deletions src/bare-metal/useful-crates/spin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use spin::mutex::SpinMutex;
static COUNTER: SpinMutex<u32> = SpinMutex::new(0);

fn main() {
println!("count: {}", COUNTER.lock());
dbg!(COUNTER.lock());
*COUNTER.lock() += 2;
println!("count: {}", COUNTER.lock());
dbg!(COUNTER.lock());
}
```

Expand Down
4 changes: 2 additions & 2 deletions src/concurrency/threads/scoped.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::thread;
fn foo() {
let s = String::from("Hello");
thread::spawn(|| {
println!("Length: {}", s.len());
dbg!(s.len());
});
}

Expand All @@ -30,7 +30,7 @@ fn foo() {
let s = String::from("Hello");
thread::scope(|scope| {
scope.spawn(|| {
println!("Length: {}", s.len());
dbg!(s.len());
});
});
}
Expand Down