diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-28 18:12:04 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-28 18:12:04 +0530 |
| commit | 5299d36c52c71d22031f2c0ea4badee412ea6861 (patch) | |
| tree | 631886aed19da786469f2bb386907ca007e6b392 | |
| parent | 474062da5dfa2f942a7aa9f97ec5c7ce3a64657a (diff) | |
| parent | 07afd04d344378c359e0dd2d71deee67445c70ca (diff) | |
| download | rust-5299d36c52c71d22031f2c0ea4badee412ea6861.tar.gz rust-5299d36c52c71d22031f2c0ea4badee412ea6861.zip | |
Rollup merge of #23751 - tshepang:do-not-hardcode-the-growth, r=Manishearth
I found the arbitrary `10` surprising. A better method name, in such a case, would be `grow_by_10` :)
| -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 85472ff5db7..41ef705f098 100644 --- a/src/doc/trpl/method-syntax.md +++ b/src/doc/trpl/method-syntax.md @@ -100,8 +100,8 @@ impl Circle { std::f64::consts::PI * (self.radius * self.radius) } - fn grow(&self) -> Circle { - Circle { x: self.x, y: self.y, radius: (self.radius * 10.0) } + fn grow(&self, increment: f64) -> Circle { + Circle { x: self.x, y: self.y, radius: self.radius + increment } } } @@ -109,7 +109,7 @@ fn main() { let c = Circle { x: 0.0, y: 0.0, radius: 2.0 }; println!("{}", c.area()); - let d = c.grow().area(); + let d = c.grow(2.0).area(); println!("{}", d); } ``` @@ -124,7 +124,7 @@ fn grow(&self) -> Circle { ``` We just say we're returning a `Circle`. With this method, we can grow a new -circle with an area that's 100 times larger than the old one. +circle to any arbitrary size. ## Static methods |
