Skip to content

Commit 213773c

Browse files
committed
Fix tasks tutorial tests
1 parent 4ec658e commit 213773c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

doc/tutorial-tasks.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ come in a variety of forms, each one appropriate for a different use case. In
150150
what follows, we cover the most commonly used varieties.
151151

152152
The simplest way to create a pipe is to use the `pipes::stream`
153-
function to create a `(Chan, Port)` pair. In Rust parlance, a *channel*
153+
function to create a `(Port, Chan)` pair. In Rust parlance, a *channel*
154154
is a sending endpoint of a pipe, and a *port* is the receiving
155155
endpoint. Consider the following example of calculating two results
156156
concurrently:
@@ -159,7 +159,7 @@ concurrently:
159159
use task::spawn;
160160
use pipes::{stream, Port, Chan};
161161
162-
let (chan, port): (Chan<int>, Port<int>) = stream();
162+
let (port, chan): (Port<int>, Chan<int>) = stream();
163163
164164
do spawn |move chan| {
165165
let result = some_expensive_computation();
@@ -179,7 +179,7 @@ a tuple into its component parts).
179179

180180
~~~~
181181
# use pipes::{stream, Chan, Port};
182-
let (chan, port): (Chan<int>, Port<int>) = stream();
182+
let (port, chan): (Port<int>, Chan<int>) = stream();
183183
~~~~
184184

185185
The child task will use the channel to send data to the parent task,
@@ -191,7 +191,7 @@ spawns the child task.
191191
# use task::spawn;
192192
# use pipes::{stream, Port, Chan};
193193
# fn some_expensive_computation() -> int { 42 }
194-
# let (chan, port) = stream();
194+
# let (port, chan) = stream();
195195
do spawn |move chan| {
196196
let result = some_expensive_computation();
197197
chan.send(result);
@@ -211,7 +211,7 @@ port:
211211
~~~~
212212
# use pipes::{stream, Port, Chan};
213213
# fn some_other_expensive_computation() {}
214-
# let (chan, port) = stream::<int>();
214+
# let (port, chan) = stream::<int>();
215215
# chan.send(0);
216216
some_other_expensive_computation();
217217
let result = port.recv();
@@ -227,7 +227,7 @@ following program is ill-typed:
227227
# use task::{spawn};
228228
# use pipes::{stream, Port, Chan};
229229
# fn some_expensive_computation() -> int { 42 }
230-
let (chan, port) = stream();
230+
let (port, chan) = stream();
231231
232232
do spawn |move chan| {
233233
chan.send(some_expensive_computation());
@@ -247,7 +247,7 @@ Instead we can use a `SharedChan`, a type that allows a single
247247
# use task::spawn;
248248
use pipes::{stream, SharedChan};
249249
250-
let (chan, port) = stream();
250+
let (port, chan) = stream();
251251
let chan = SharedChan(move chan);
252252
253253
for uint::range(0, 3) |init_val| {
@@ -282,7 +282,7 @@ might look like the example below.
282282
283283
// Create a vector of ports, one for each child task
284284
let ports = do vec::from_fn(3) |init_val| {
285-
let (chan, port) = stream();
285+
let (port, chan) = stream();
286286
do spawn |move chan| {
287287
chan.send(some_expensive_computation(init_val));
288288
}
@@ -397,7 +397,7 @@ before returning. Hence:
397397
# use task::{spawn, try};
398398
# fn sleep_forever() { loop { task::yield() } }
399399
# do task::try {
400-
let (sender, receiver): (Chan<int>, Port<int>) = stream();
400+
let (receiver, sender): (Port<int>, Chan<int>) = stream();
401401
do spawn |move receiver| { // Bidirectionally linked
402402
// Wait for the supervised child task to exist.
403403
let message = receiver.recv();

0 commit comments

Comments
 (0)