diff options
| author | bors <bors@rust-lang.org> | 2015-04-25 03:43:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-25 03:43:31 +0000 |
| commit | a40261ac91dd80b21830cc94de6132744e0c5078 (patch) | |
| tree | 023666901a4f040367389290d46a22c97ae7d8ce /src/doc/trpl/method-syntax.md | |
| parent | f9e53c7f2c8285f3422ac7ac091349ce572c4baa (diff) | |
| parent | 23b1d172a8245f810f179d939488325fff005158 (diff) | |
| download | rust-a40261ac91dd80b21830cc94de6132744e0c5078.tar.gz rust-a40261ac91dd80b21830cc94de6132744e0c5078.zip | |
Auto merge of #24798 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24662, #24722, #24725, #24729, #24736, #24749, #24751, #24766, #24769, #24772, #24775, #24790 - Failed merges: #24760
Diffstat (limited to 'src/doc/trpl/method-syntax.md')
| -rw-r--r-- | src/doc/trpl/method-syntax.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/doc/trpl/method-syntax.md b/src/doc/trpl/method-syntax.md index 5853f3d679c..1445d39fe87 100644 --- a/src/doc/trpl/method-syntax.md +++ b/src/doc/trpl/method-syntax.md @@ -18,7 +18,7 @@ foo.bar().baz(); Luckily, as you may have guessed with the leading question, you can! Rust provides the ability to use this ‘method call syntax’ via the `impl` keyword. -## Method calls +# Method calls Here’s how it works: @@ -83,7 +83,7 @@ impl Circle { } ``` -## Chaining method calls +# Chaining method calls So, now we know how to call a method, such as `foo.bar()`. But what about our original example, `foo.bar().baz()`? This is called ‘method chaining’, and we @@ -127,7 +127,7 @@ fn grow(&self) -> Circle { We just say we’re returning a `Circle`. With this method, we can grow a new circle to any arbitrary size. -## Static methods +# Static methods You can also define methods that do not take a `self` parameter. Here’s a pattern that’s very common in Rust code: @@ -158,7 +158,7 @@ This ‘static method’ builds a new `Circle` for us. Note that static methods are called with the `Struct::method()` syntax, rather than the `ref.method()` syntax. -## Builder Pattern +# Builder Pattern Let’s say that we want our users to be able to create Circles, but we will allow them to only set the properties they care about. Otherwise, the `x` |
