Fix type inference problems in tests and docs
This commit is contained in:
parent
da8023d653
commit
537889aa78
4 changed files with 23 additions and 23 deletions
|
|
@ -480,14 +480,12 @@ use std::sync::{Arc,Mutex};
|
|||
fn main() {
|
||||
let numbers = Arc::new(Mutex::new(vec![1is, 2, 3]));
|
||||
|
||||
for i in 0..3 {
|
||||
for i in 0us..3 {
|
||||
let number = numbers.clone();
|
||||
Thread::spawn(move || {
|
||||
let mut array = number.lock().unwrap();
|
||||
|
||||
array[i as usize] += 1;
|
||||
|
||||
println!("numbers[{}] is {}", i, array[i as usize]);
|
||||
array[i] += 1;
|
||||
println!("numbers[{}] is {}", i, array[i]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ We now loop forever with `loop` and use `break` to break out early.
|
|||
iteration. This will only print the odd numbers:
|
||||
|
||||
```{rust}
|
||||
for x in 0..10 {
|
||||
for x in 0u32..10 {
|
||||
if x % 2 == 0 { continue; }
|
||||
|
||||
println!("{}", x);
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ for init_val in 0 .. 3 {
|
|||
}
|
||||
|
||||
let result = rx.recv().unwrap() + rx.recv().unwrap() + rx.recv().unwrap();
|
||||
# fn some_expensive_computation(_i: u32) -> u32 { 42 }
|
||||
# fn some_expensive_computation(_i: i32) -> i32 { 42 }
|
||||
```
|
||||
|
||||
Cloning a `Sender` produces a new handle to the same channel, allowing multiple
|
||||
|
|
@ -207,7 +207,7 @@ let rxs = (0 .. 3).map(|&:init_val| {
|
|||
|
||||
// Wait on each port, accumulating the results
|
||||
let result = rxs.iter().fold(0, |&:accum, rx| accum + rx.recv().unwrap() );
|
||||
# fn some_expensive_computation(_i: u32) -> u32 { 42 }
|
||||
# fn some_expensive_computation(_i: i32) -> i32 { 42 }
|
||||
```
|
||||
|
||||
## Backgrounding computations: Futures
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue