Skip to content

Commit 5299d36

Browse files
committed
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` :)
2 parents 474062d + 07afd04 commit 5299d36

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/doc/trpl/method-syntax.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ impl Circle {
100100
std::f64::consts::PI * (self.radius * self.radius)
101101
}
102102
103-
fn grow(&self) -> Circle {
104-
Circle { x: self.x, y: self.y, radius: (self.radius * 10.0) }
103+
fn grow(&self, increment: f64) -> Circle {
104+
Circle { x: self.x, y: self.y, radius: self.radius + increment }
105105
}
106106
}
107107
108108
fn main() {
109109
let c = Circle { x: 0.0, y: 0.0, radius: 2.0 };
110110
println!("{}", c.area());
111111
112-
let d = c.grow().area();
112+
let d = c.grow(2.0).area();
113113
println!("{}", d);
114114
}
115115
```
@@ -124,7 +124,7 @@ fn grow(&self) -> Circle {
124124
```
125125

126126
We just say we're returning a `Circle`. With this method, we can grow a new
127-
circle with an area that's 100 times larger than the old one.
127+
circle to any arbitrary size.
128128

129129
## Static methods
130130

0 commit comments

Comments
 (0)