# struct Philosopher {
# name: String,
# }
-#
+#
# impl Philosopher {
# fn new(name: &str) -> Philosopher {
# Philosopher {
# }
# }
# }
-#
+#
fn main() {
let p1 = Philosopher::new("Judith Butler");
let p2 = Philosopher::new("Gilles Deleuze");
```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);
}
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);
struct Philosopher {
name: String,
-}
+}
-impl Philosopher {
+impl Philosopher {
fn new(name: &str) -> Philosopher {
Philosopher {
name: name.to_string(),
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
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.
```