@@ -151,15 +151,15 @@ look at `main()` again:
151
151
# struct Philosopher {
152
152
# name : String ,
153
153
# }
154
- #
154
+ #
155
155
# impl Philosopher {
156
156
# fn new (name : & str ) -> Philosopher {
157
157
# Philosopher {
158
158
# name : name . to_string (),
159
159
# }
160
160
# }
161
161
# }
162
- #
162
+ #
163
163
fn main () {
164
164
let p1 = Philosopher :: new (" Judith Butler" );
165
165
let p2 = Philosopher :: new (" Gilles Deleuze" );
@@ -197,15 +197,15 @@ a method, and then loop through all the philosophers, calling it:
197
197
``` rust
198
198
struct Philosopher {
199
199
name : String ,
200
- }
200
+ }
201
201
202
- impl Philosopher {
202
+ impl Philosopher {
203
203
fn new (name : & str ) -> Philosopher {
204
204
Philosopher {
205
205
name : name . to_string (),
206
206
}
207
207
}
208
-
208
+
209
209
fn eat (& self ) {
210
210
println! (" {} is done eating." , self . name);
211
211
}
@@ -267,15 +267,15 @@ use std::thread;
267
267
268
268
struct Philosopher {
269
269
name : String ,
270
- }
270
+ }
271
271
272
- impl Philosopher {
272
+ impl Philosopher {
273
273
fn new (name : & str ) -> Philosopher {
274
274
Philosopher {
275
275
name : name . to_string (),
276
276
}
277
277
}
278
-
278
+
279
279
fn eat (& self ) {
280
280
println! (" {} is eating." , self . name);
281
281
@@ -348,9 +348,9 @@ use std::thread;
348
348
349
349
struct Philosopher {
350
350
name : String ,
351
- }
351
+ }
352
352
353
- impl Philosopher {
353
+ impl Philosopher {
354
354
fn new (name : & str ) -> Philosopher {
355
355
Philosopher {
356
356
name : name . to_string (),
@@ -401,7 +401,7 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
401
401
While this is only five lines, they’re a dense five. Let’s break it down.
402
402
403
403
``` rust,ignore
404
- let handles: Vec<_> =
404
+ let handles: Vec<_> =
405
405
```
406
406
407
407
We introduce a new binding, called ` handles ` . We’ve given it this name because
@@ -460,15 +460,15 @@ If you run this program, you’ll see that the philosophers eat out of order!
460
460
We have multi-threading!
461
461
462
462
``` text
463
+ Judith Butler is eating.
463
464
Gilles Deleuze is eating.
464
- Gilles Deleuze is done eating.
465
+ Karl Marx is eating.
465
466
Emma Goldman is eating.
466
- Emma Goldman is done eating.
467
467
Michel Foucault is eating.
468
- Judith Butler is eating.
469
468
Judith Butler is done eating.
470
- Karl Marx is eating.
469
+ Gilles Deleuze is done eating.
471
470
Karl Marx is done eating.
471
+ Emma Goldman is done eating.
472
472
Michel Foucault is done eating.
473
473
```
474
474
0 commit comments