diff options
| author | bors <bors@rust-lang.org> | 2015-07-13 09:15:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-07-13 09:15:12 +0000 |
| commit | a16a4173c96a669412b3740dd7acba7d41b66b39 (patch) | |
| tree | 70d4c2107f474c023d9da04eecbef24ce81fcfb9 | |
| parent | 5f552a5da53e8164a13c337b6cbe39c3f20f35ff (diff) | |
| parent | 49e45833f8a2a97a753a4229ffc84f8a746e8f3b (diff) | |
| download | rust-a16a4173c96a669412b3740dd7acba7d41b66b39.tar.gz rust-a16a4173c96a669412b3740dd7acba7d41b66b39.zip | |
Auto merge of #26990 - rwz:patch-1, r=alexcrichton
The current example does not illustrate threaded behavior imo.
| -rw-r--r-- | src/doc/trpl/dining-philosophers.md | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/doc/trpl/dining-philosophers.md b/src/doc/trpl/dining-philosophers.md index b24d50c890d..9539cd3447c 100644 --- a/src/doc/trpl/dining-philosophers.md +++ b/src/doc/trpl/dining-philosophers.md @@ -151,7 +151,7 @@ look at `main()` again: # struct Philosopher { # name: String, # } -# +# # impl Philosopher { # fn new(name: &str) -> Philosopher { # Philosopher { @@ -159,7 +159,7 @@ look at `main()` again: # } # } # } -# +# fn main() { let p1 = Philosopher::new("Judith Butler"); let p2 = Philosopher::new("Gilles Deleuze"); @@ -197,15 +197,15 @@ a method, and then loop through all the philosophers, calling it: ```rust struct Philosopher { name: String, -} +} -impl Philosopher { +impl Philosopher { fn new(name: &str) -> Philosopher { Philosopher { name: name.to_string(), } } - + fn eat(&self) { println!("{} is done eating.", self.name); } @@ -267,15 +267,15 @@ use std::thread; struct Philosopher { name: String, -} +} -impl Philosopher { +impl Philosopher { fn new(name: &str) -> Philosopher { Philosopher { name: name.to_string(), } } - + fn eat(&self) { println!("{} is eating.", self.name); @@ -348,9 +348,9 @@ use std::thread; struct Philosopher { name: String, -} +} -impl Philosopher { +impl Philosopher { fn new(name: &str) -> Philosopher { Philosopher { name: name.to_string(), @@ -401,7 +401,7 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| { While this is only five lines, they’re a dense five. Let’s break it down. ```rust,ignore -let handles: Vec<_> = +let handles: Vec<_> = ``` 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! We have multi-threading! ```text +Judith Butler is eating. Gilles Deleuze is eating. -Gilles Deleuze is done eating. +Karl Marx is eating. Emma Goldman is eating. -Emma Goldman is done eating. Michel Foucault is eating. -Judith Butler is eating. Judith Butler is done eating. -Karl Marx is eating. +Gilles Deleuze is done eating. Karl Marx is done eating. +Emma Goldman is done eating. Michel Foucault is done eating. ``` |
