File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -305,21 +305,17 @@ copying.
305305# Circle(Point, f64), // origin, radius
306306# Rectangle(Point, Size) // upper-left, dimensions
307307# }
308- # static tau: f64 = 6.28;
309308fn compute_area(shape: &Shape) -> f64 {
310309 match *shape {
311- Circle(_, radius) => 0.5 * tau * radius * radius,
310+ Circle(_, radius) => 2.0 * std::f64::consts::PI * radius * radius,
312311 Rectangle(_, ref size) => size.w * size.h
313312 }
314313}
315314~~~
316315
317316The first case matches against circles. Here, the pattern extracts the
318317radius from the shape variant and the action uses it to compute the
319- area of the circle. (Like any up-to-date engineer, we use the [ tau
320- circle constant] [ tau ] and not that dreadfully outdated notion of pi).
321-
322- [ tau ] : http://www.math.utah.edu/~palais/pi.html
318+ area of the circle.
323319
324320The second match is more interesting. Here we match against a
325321rectangle and extract its size: but rather than copy the ` size `
You can’t perform that action at this time.
0 commit comments