Skip to content

Commit 9ed27df

Browse files
raindevsteveklabnik
authored andcommitted
Fix intro concurrency examples compilation warns
* Use range notation instead of deprecated `range()` * Remove deprecated `u` integer suffixes used in ranges * Replace deprecated `i` integer suffixes with `is` for vector numbers `Thread::spawn()` still gives "use of unstable item" warning which I hadn't found a way to fix.
1 parent 873ae55 commit 9ed27df

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/doc/intro.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ Let's see an example. This Rust code will not compile:
424424
use std::thread::Thread;
425425
426426
fn main() {
427-
let mut numbers = vec![1i, 2i, 3i];
427+
let mut numbers = vec![1is, 2is, 3is];
428428
429-
for i in range(0u, 3u) {
429+
for i in 0..3 {
430430
Thread::spawn(move || {
431-
for j in range(0, 3) { numbers[j] += 1 }
431+
for j in 0..3 { numbers[j] += 1 }
432432
});
433433
}
434434
}
@@ -478,9 +478,9 @@ use std::thread::Thread;
478478
use std::sync::{Arc,Mutex};
479479
480480
fn main() {
481-
let numbers = Arc::new(Mutex::new(vec![1i, 2i, 3i]));
481+
let numbers = Arc::new(Mutex::new(vec![1is, 2is, 3is]));
482482
483-
for i in range(0u, 3u) {
483+
for i in 0..3 {
484484
let number = numbers.clone();
485485
Thread::spawn(move || {
486486
let mut array = number.lock().unwrap();

0 commit comments

Comments
 (0)