]> git.lizzy.rs Git - rust.git/commitdiff
Fix intro concurrency examples compilation warns
authorAndrew Barchuk <raindev@icloud.com>
Tue, 13 Jan 2015 21:22:32 +0000 (23:22 +0200)
committerSteve Klabnik <steve@steveklabnik.com>
Sat, 17 Jan 2015 15:49:49 +0000 (10:49 -0500)
* 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.

src/doc/intro.md

index d93b680ae6de704cb83fd73394475fb1681b88e8..b5e5fab7469c0886a3af744640c2d88a07316364 100644 (file)
@@ -424,11 +424,11 @@ Let's see an example. This Rust code will not compile:
 use std::thread::Thread;
 
 fn main() {
-    let mut numbers = vec![1i, 2i, 3i];
+    let mut numbers = vec![1is, 2is, 3is];
 
-    for i in range(0u, 3u) {
+    for i in 0..3 {
         Thread::spawn(move || {
-            for j in range(0, 3) { numbers[j] += 1 }
+            for j in 0..3 { numbers[j] += 1 }
         });
     }
 }
@@ -478,9 +478,9 @@ use std::thread::Thread;
 use std::sync::{Arc,Mutex};
 
 fn main() {
-    let numbers = Arc::new(Mutex::new(vec![1i, 2i, 3i]));
+    let numbers = Arc::new(Mutex::new(vec![1is, 2is, 3is]));
 
-    for i in range(0u, 3u) {
+    for i in 0..3 {
         let number = numbers.clone();
         Thread::spawn(move || {
             let mut array = number.lock().unwrap();