about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-11-05 12:43:03 +0100
committerSteve Klabnik <steve@steveklabnik.com>2015-11-05 12:43:03 +0100
commitf04e77d598ea24869b47c03176308f9ec1da0dba (patch)
treea8a890916701733d4f51221ab6b399048824de5f
parent255b81d22cb9e5df2a4677dc7d74dd1941cfda8c (diff)
parent0c93e727c2bc6fd483500db6192e1aff21d2acac (diff)
downloadrust-f04e77d598ea24869b47c03176308f9ec1da0dba.tar.gz
rust-f04e77d598ea24869b47c03176308f9ec1da0dba.zip
Rollup merge of #29571 - steveklabnik:gh29322, r=apasel422
Fixes #29322
-rw-r--r--src/doc/trpl/method-syntax.md31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/doc/trpl/method-syntax.md b/src/doc/trpl/method-syntax.md
index d31d8232470..41c134b29f3 100644
--- a/src/doc/trpl/method-syntax.md
+++ b/src/doc/trpl/method-syntax.md
@@ -43,8 +43,6 @@ fn main() {
 
 This will print `12.566371`.
 
-
-
 We’ve made a `struct` that represents a circle. We then write an `impl` block,
 and inside it, define a method, `area`.
 
@@ -83,6 +81,35 @@ impl Circle {
 }
 ```
 
+You can use as many `impl` blocks as you’d like. The previous example could
+have also been written like this:
+
+```rust
+struct Circle {
+    x: f64,
+    y: f64,
+    radius: f64,
+}
+
+impl Circle {
+    fn reference(&self) {
+       println!("taking self by reference!");
+    }
+}
+
+impl Circle {
+    fn mutable_reference(&mut self) {
+       println!("taking self by mutable reference!");
+    }
+}
+
+impl Circle {
+    fn takes_ownership(self) {
+       println!("taking ownership of self!");
+    }
+}
+```
+
 # Chaining method calls
 
 So, now we know how to call a method, such as `foo.bar()`. But what about our