about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-02 14:50:24 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-02 14:50:24 -0700
commit979f7cd7d7f2e3312006a212ca7a3484ebbc0140 (patch)
tree3f7e5046fe7eab3dfc3bac0f8fae7220049a00cb
parent67717b61e61ac70fdad19e5a3f5392e663646eb3 (diff)
parent16cca6dbada93a7468825e0eb106ea05a7417c01 (diff)
downloadrust-979f7cd7d7f2e3312006a212ca7a3484ebbc0140.tar.gz
rust-979f7cd7d7f2e3312006a212ca7a3484ebbc0140.zip
rollup merge of #17695 : steveklabnik/various_docs
-rw-r--r--src/doc/guide-lifetimes.md8
-rw-r--r--src/doc/guide.md26
2 files changed, 14 insertions, 20 deletions
diff --git a/src/doc/guide-lifetimes.md b/src/doc/guide-lifetimes.md
index 66faee3fa04..dd79d63d514 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) => 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`
diff --git a/src/doc/guide.md b/src/doc/guide.md
index 074dfc17b0d..3ffb7cad0a4 100644
--- a/src/doc/guide.md
+++ b/src/doc/guide.md
@@ -659,14 +659,12 @@ error: mismatched types: expected `int` but found `()` (expected int but found (
 ```
 
 We expected an integer, but we got `()`. `()` is pronounced 'unit', and is a
-special type in Rust's type system. `()` is different than `null` in other
-languages, because `()` is distinct from other types. For example, in C, `null`
-is a valid value for a variable of type `int`. In Rust, `()` is _not_ a valid
-value for a variable of type `int`. It's only a valid value for variables of
-the type `()`, which aren't very useful. Remember how we said statements don't
-return a value? Well, that's the purpose of unit in this case. The semicolon
-turns any expression into a statement by throwing away its value and returning
-unit instead.
+special type in Rust's type system. In Rust, `()` is _not_ a valid value for a
+variable of type `int`. It's only a valid value for variables of the type `()`,
+which aren't very useful. Remember how we said statements don't return a value?
+Well, that's the purpose of unit in this case. The semicolon turns any
+expression into a statement by throwing away its value and returning unit
+instead.
 
 There's one more time in which you won't see a semicolon at the end of a line
 of Rust code. For that, we'll need our next concept: functions.
@@ -1680,11 +1678,11 @@ just `int`s.
 
 Rust provides a method on these `IoResult<T>`s called `ok()`, which does the
 same thing as our `match` statement, but assuming that we have a valid value.
-If we don't, it will terminate our program. In this case, if we can't get
-input, our program doesn't work, so we're okay with that. In most cases, we
-would want to handle the error case explicitly. The result of `ok()` has a
-method, `expect()`, which allows us to give an error message if this crash
-happens.
+We then call `expect()` on the result, which will terminate our program if we
+don't have a valid value. In this case, if we can't get input, our program
+doesn't work, so we're okay with that. In most cases, we would want to handle
+the error case explicitly. `expect()` allows us to give an error message if
+this crash happens.
 
 We will cover the exact details of how all of this works later in the Guide.
 For now, this gives you enough of a basic understanding to work with.
@@ -2030,7 +2028,7 @@ fn main() {
     match cmp(input, secret_number) {
         Less    => println!("Too small!"),
         Greater => println!("Too big!"),
-        Equal   => { println!("You win!"); },
+        Equal   => println!("You win!"),
     }
 }