diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-09-18 22:33:49 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-10-12 20:43:37 -0700 |
| commit | ea5e3d21ff5ef8b4d30b588d0cd65859ffa3bab1 (patch) | |
| tree | 3a490d6c9d82154a49861a6fb6ace98bc047b5d6 /doc | |
| parent | d0ed13c4bdb19b2e9c445908775794f0880a301c (diff) | |
Make moves explicit in doc examples
Had to remove the buffalo example. It was awkward to update for explicit moves.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/tutorial-tasks.md | 18 | ||||
| -rw-r--r-- | doc/tutorial.md | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md index 8a0cda3e820..2d203400dda 100644 --- a/doc/tutorial-tasks.md +++ b/doc/tutorial-tasks.md @@ -161,7 +161,7 @@ use pipes::{stream, Port, Chan}; let (chan, port): (Chan<int>, Port<int>) = stream(); -do spawn { +do spawn |move chan| { let result = some_expensive_computation(); chan.send(result); } @@ -192,7 +192,7 @@ spawns the child task. # use pipes::{stream, Port, Chan}; # fn some_expensive_computation() -> int { 42 } # let (chan, port) = stream(); -do spawn { +do spawn |move chan| { let result = some_expensive_computation(); chan.send(result); } @@ -229,7 +229,7 @@ following program is ill-typed: # fn some_expensive_computation() -> int { 42 } let (chan, port) = stream(); -do spawn { +do spawn |move chan| { chan.send(some_expensive_computation()); } @@ -253,7 +253,7 @@ let chan = SharedChan(move chan); for uint::range(0, 3) |init_val| { // Create a new channel handle to distribute to the child task let child_chan = chan.clone(); - do spawn { + do spawn |move child_chan| { child_chan.send(some_expensive_computation(init_val)); } } @@ -283,10 +283,10 @@ might look like the example below. // Create a vector of ports, one for each child task let ports = do vec::from_fn(3) |init_val| { let (chan, port) = stream(); - do spawn { + do spawn |move chan| { chan.send(some_expensive_computation(init_val)); } - port + move port }; // Wait on each port, accumulating the results @@ -398,13 +398,13 @@ before returning. Hence: # fn sleep_forever() { loop { task::yield() } } # do task::try { let (sender, receiver): (Chan<int>, Port<int>) = stream(); -do spawn { // Bidirectionally linked +do spawn |move receiver| { // Bidirectionally linked // Wait for the supervised child task to exist. let message = receiver.recv(); // Kill both it and the parent task. assert message != 42; } -do try { // Unidirectionally linked +do try |move sender| { // Unidirectionally linked sender.send(42); sleep_forever(); // Will get woken up by force } @@ -505,7 +505,7 @@ Here is the code for the parent task: let (from_child, to_child) = DuplexStream(); -do spawn || { +do spawn |move to_child| { stringifier(&to_child); }; diff --git a/doc/tutorial.md b/doc/tutorial.md index 12850a92a03..8746cf026f9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1827,7 +1827,7 @@ fn map<T, U>(vector: &[T], function: fn(v: &T) -> U) -> ~[U] { for vec::each(vector) |element| { accumulator.push(function(element)); } - return accumulator; + return (move accumulator); } ~~~~ |
