Skip to content

Commit

Permalink
Make scoped thread examples consistent
Browse files Browse the repository at this point in the history
This is a followup to #1020.
  • Loading branch information
mgeisler committed Jun 5, 2024
1 parent bd270fb commit 333e97d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/concurrency/threads/scoped.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ However, you can use a [scoped thread][1] for this:
```rust,editable
use std::thread;
fn main() {
fn foo() {
let s = String::from("Hello");
thread::scope(|scope| {
scope.spawn(|| {
println!("Length: {}", s.len());
});
});
}
fn main() {
foo();
}
```

[1]: https://doc.rust-lang.org/std/thread/fn.scope.html
Expand Down

0 comments on commit 333e97d

Please sign in to comment.