@@ -41,7 +41,7 @@ concurrency: particularly, ownership. The language leaves the implementation
4141details to the standard library.
4242
4343The ` spawn ` function has a very simple type signature: `fn spawn(f: proc():
44- Send)`. Because it accepts only procs, and procs contain only owned data,
44+ Send)`. Because it accepts only procs, and procs contain only owned data,
4545` spawn ` can safely move the entire proc and all its associated state into an
4646entirely different task for execution. Like any closure, the function passed to
4747` spawn ` may capture an environment that it carries across tasks.
@@ -213,7 +213,7 @@ println!("fib(50) = {}", delayed_fib.get())
213213# }
214214```
215215
216- The call to ` future::spawn ` returns immediately a ` future ` object regardless of
216+ The call to ` future::spawn ` immediately returns a ` future ` object regardless of
217217how long it takes to run ` fib(50) ` . You can then make yourself a sandwich while
218218the computation of ` fib ` is running. The result of the execution of the method
219219is obtained by calling ` get ` on the future. This call will block until the
@@ -297,7 +297,7 @@ let numbers_arc = Arc::new(numbers);
297297```
298298
299299and a clone is captured for each task via a procedure. This only copies
300- the wrapper and not it's contents. Within the task's procedure, the captured
300+ the wrapper and not its contents. Within the task's procedure, the captured
301301Arc reference can be used as a shared reference to the underlying vector as
302302if it were local.
303303
@@ -323,20 +323,20 @@ Rust has a built-in mechanism for raising exceptions. The `fail!()` macro
323323(which can also be written with an error string as an argument: `fail!(
324324~ reason)` ) and the ` assert!` construct (which effectively calls ` fail!()` if a
325325boolean expression is false) are both ways to raise exceptions. When a task
326- raises an exception the task unwinds its stack--- running destructors and
327- freeing memory along the way--- and then exits. Unlike exceptions in C++,
326+ raises an exception, the task unwinds its stack— running destructors and
327+ freeing memory along the way— and then exits. Unlike exceptions in C++,
328328exceptions in Rust are unrecoverable within a single task: once a task fails,
329329there is no way to "catch" the exception.
330330
331331While it isn't possible for a task to recover from failure, tasks may notify
332332each other of failure. The simplest way of handling task failure is with the
333- ` try ` function, which is similar to ` spawn ` , but immediately blocks waiting for
334- the child task to finish. ` try ` returns a value of type `Result<T, Box<Any +
335- Send>>` . ` Result` is an ` enum` type with two variants: ` Ok ` and ` Err`. In this
336- case, because the type arguments to ` Result ` are ` int ` and ` () ` , callers can
337- pattern-match on a result to check whether it's an ` Ok ` result with an ` int `
338- field (representing a successful result) or an ` Err ` result (representing
339- termination with an error).
333+ ` try ` function, which is similar to ` spawn ` , but immediately blocks and waits
334+ for the child task to finish. ` try ` returns a value of type
335+ ` Result<T, Box<Any + Send>>` . ` Result ` is an ` enum ` type with two variants:
336+ ` Ok ` and ` Err ` . In this case, because the type arguments to ` Result ` are ` int `
337+ and ` () ` , callers can pattern-match on a result to check whether it's an ` Ok `
338+ result with an ` int ` field (representing a successful result) or an ` Err ` result
339+ (representing termination with an error).
340340
341341``` {rust}
342342# use std::task;
@@ -369,4 +369,4 @@ the entire program (perhaps you're writing an assert which, if it trips,
369369indicates an unrecoverable logic error); in other cases you might want to
370370contain the failure at a certain boundary (perhaps a small piece of input from
371371the outside world, which you happen to be processing in parallel, is malformed
372- and its processing task can't proceed).
372+ such that the processing task cannot proceed).
0 commit comments