Skip to content

[doc] Fix multi-threading example in dining-philosophers #26990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/doc/trpl/dining-philosophers.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ look at `main()` again:
# struct Philosopher {
# name: String,
# }
#
#
# impl Philosopher {
# fn new(name: &str) -> Philosopher {
# Philosopher {
# name: name.to_string(),
# }
# }
# }
#
#
fn main() {
let p1 = Philosopher::new("Judith Butler");
let p2 = Philosopher::new("Gilles Deleuze");
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
```

Expand Down