diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2014-10-01 17:10:59 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2014-10-01 17:11:05 -0400 |
| commit | fc818ff33b8b83ec1c669660acab37fc6576eee4 (patch) | |
| tree | 8d22bf055310a050d33dbbb5d85255e025fc5a07 /src/doc | |
| parent | 49fcb27df63b845c42d4883c47d2cfc512edeb78 (diff) | |
| download | rust-fc818ff33b8b83ec1c669660acab37fc6576eee4.tar.gz rust-fc818ff33b8b83ec1c669660acab37fc6576eee4.zip | |
:fire: τ
Fixes #17674
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/guide-lifetimes.md | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/doc/guide-lifetimes.md b/src/doc/guide-lifetimes.md index 66faee3fa04..545d286c5d7 100644 --- a/src/doc/guide-lifetimes.md +++ b/src/doc/guide-lifetimes.md @@ -305,10 +305,9 @@ copying. # Circle(Point, f64), // origin, radius # Rectangle(Point, Size) // upper-left, dimensions # } -# static tau: f64 = 6.28; fn compute_area(shape: &Shape) -> f64 { match *shape { - Circle(_, radius) => 0.5 * tau * radius * radius, + Circle(_, radius) => 2.0 * std::f64::consts::PI * radius * radius, Rectangle(_, ref size) => size.w * size.h } } @@ -316,10 +315,7 @@ fn compute_area(shape: &Shape) -> f64 { The first case matches against circles. Here, the pattern extracts the radius from the shape variant and the action uses it to compute the -area of the circle. (Like any up-to-date engineer, we use the [tau -circle constant][tau] and not that dreadfully outdated notion of pi). - -[tau]: http://www.math.utah.edu/~palais/pi.html +area of the circle. The second match is more interesting. Here we match against a rectangle and extract its size: but rather than copy the `size` |
