Skip to content

Commit a6ebd26

Browse files
committed
Update example that uses deprecated Thread::scoped
1 parent ead9ab8 commit a6ebd26

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/doc/intro.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,11 @@ safe concurrent programs.
389389
Here's an example of a concurrent Rust program:
390390
391391
```{rust}
392-
use std::thread::Thread;
392+
use std::thread;
393393
394394
fn main() {
395395
let guards: Vec<_> = (0..10).map(|_| {
396-
Thread::scoped(|| {
396+
thread::scoped(|| {
397397
println!("Hello, world!");
398398
})
399399
}).collect();
@@ -421,13 +421,13 @@ problem.
421421
Let's see an example. This Rust code will not compile:
422422
423423
```{rust,ignore}
424-
use std::thread::Thread;
424+
use std::thread;
425425
426426
fn main() {
427427
let mut numbers = vec![1, 2, 3];
428428
429429
let guards: Vec<_> = (0..3).map(|i| {
430-
Thread::scoped(move || {
430+
thread::scoped(move || {
431431
numbers[i] += 1;
432432
println!("numbers[{}] is {}", i, numbers[i]);
433433
});
@@ -439,7 +439,7 @@ It gives us this error:
439439
440440
```text
441441
7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
442-
7 Thread::scoped(move || {
442+
7 thread::scoped(move || {
443443
8 numbers[i] += 1;
444444
9 println!("numbers[{}] is {}", i, numbers[i]);
445445
10 });
@@ -471,15 +471,15 @@ mutation doesn't cause a data race.
471471
Here's what using an Arc with a Mutex looks like:
472472
473473
```{rust}
474-
use std::thread::Thread;
474+
use std::thread;
475475
use std::sync::{Arc,Mutex};
476476
477477
fn main() {
478478
let numbers = Arc::new(Mutex::new(vec![1, 2, 3]));
479479
480480
let guards: Vec<_> = (0..3).map(|i| {
481481
let number = numbers.clone();
482-
Thread::scoped(move || {
482+
thread::scoped(move || {
483483
let mut array = number.lock().unwrap();
484484
array[i] += 1;
485485
println!("numbers[{}] is {}", i, array[i]);
@@ -535,13 +535,13 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
535535
safety check that makes this an error about moved values:
536536
537537
```{rust,ignore}
538-
use std::thread::Thread;
538+
use std::thread;
539539
540540
fn main() {
541541
let numbers = vec![1, 2, 3];
542542
543543
let guards: Vec<_> = (0..3).map(|i| {
544-
Thread::scoped(move || {
544+
thread::scoped(move || {
545545
println!("{}", numbers[i]);
546546
});
547547
}).collect();

0 commit comments

Comments
 (0)