mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-11-21 13:25:53 +02:00
Make scoped thread examples consistent (#2444)
This is a followup to #1020.
This commit is contained in:
parent
1a9941b39f
commit
ad7ef2e50a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user