You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/book/dining-philosophers.md
+8-5
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ short strings anyway.
148
148
One last thing you’ll notice: we just define a `Philosopher`, and seemingly
149
149
don’t do anything with it. Rust is an ‘expression based’ language, which means
150
150
that almost everything in Rust is an expression which returns a value. This is
151
-
true of functions as well, the last expression is automatically returned. Since
151
+
true of functions as well — the last expression is automatically returned. Since
152
152
we create a new `Philosopher` as the last expression of this function, we end
153
153
up returning it.
154
154
@@ -178,8 +178,8 @@ fn main() {
178
178
}
179
179
```
180
180
181
-
Here, we create five variable bindings with five new philosophers. These are my
182
-
favorite five, but you can substitute anyone you want. If we _didn’t_ define
181
+
Here, we create five variable bindings with five new philosophers.
182
+
If we _didn’t_ define
183
183
that `new()` function, it would look like this:
184
184
185
185
```rust
@@ -440,10 +440,13 @@ closure as an argument and calls that closure on each element in turn.
440
440
Here’s where the concurrency happens. The `thread::spawn` function takes a closure
441
441
as an argument and executes that closure in a new thread. This closure needs
442
442
an extra annotation, `move`, to indicate that the closure is going to take
443
-
ownership of the values it’s capturing. Primarily, the `p` variable of the
443
+
ownership of the values it’s capturing. In this case, it's the `p` variable of the
444
444
`map` function.
445
445
446
-
Inside the thread, all we do is call `eat()` on `p`. Also note that the call to `thread::spawn` lacks a trailing semicolon, making this an expression. This distinction is important, yielding the correct return value. For more details, read [Expressions vs. Statements][es].
446
+
Inside the thread, all we do is call `eat()` on `p`. Also note that
447
+
the call to `thread::spawn` lacks a trailing semicolon, making this an
448
+
expression. This distinction is important, yielding the correct return
449
+
value. For more details, read [Expressions vs. Statements][es].
0 commit comments