Address Steve nits

This commit is contained in:
Carol (Nichols || Goulding)
2016-10-13 17:50:42 -04:00
parent 3d139fd785
commit 0e8af61665
4 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -93,7 +93,7 @@ both values `IpAddrKind::V4` and `IpAddrKind::V6` are of the same type:
fn route(ip_type: IpAddrKind) { }
```
And we can call this function with either value that we have:
And we can call this function with either variant:
```rust
# enum IpAddrKind {
@@ -172,7 +172,7 @@ There's another advantage to using an enum over a struct: each variant can
store *different kinds* of data. Version four type IP addresses will always
have four numeric components that will have values between 0 and 255. If we
wanted to store `V4` addresses as four `u8`s but still express `V6` addresses
as `String`s, we wouldn't be able to with a `struct`. Enums deal with this case
as `String`s, we wouldn't be able to with a `struct`. Enums handle this case
with ease:
```rust
+6 -6
View File
@@ -15,7 +15,7 @@ the *null* feature that many other languages have. Null is a value that
means there is no value there. In languages with null, variables
can always be in one of two states: null or not-null.
The inventor of the null concept has this to say:
The inventor of null has this to say:
> I call it my billion-dollar mistake. At that time, I was designing the first
> comprehensive type system for references in an object-oriented language. My
@@ -64,11 +64,11 @@ before mentioning it so they know what significance it has here -->
<!-- We did speak about the prelude previously, in chapter 2, the Processing a
Guess section. I don't have any comments from you about it there... /Carol -->
The `<T>` is a feature of Rust we haven't talked about yet. It's a generic type
parameter, and we'll cover generics in more detail in Chapter 10. For now, all
you need to know is that this means the `Some` variant of the `Option` enum can
hold one piece of data of any type. Here are some examples of using `Option`
values to hold number types and string types:
The `<T>` syntax is a feature of Rust we haven't talked about yet. It's a
generic type parameter, and we'll cover generics in more detail in Chapter 10.
For now, all you need to know is that this means the `Some` variant of the
`Option` enum can hold one piece of data of any type. Here are some examples of
using `Option` values to hold number types and string types:
```rust
let some_number = Some(5);
+1 -1
View File
@@ -294,7 +294,7 @@ match some_u8_value {
3 => println!("three"),
5 => println!("five"),
7 => println!("seven"),
_ => {},
_ => (),
}
```
+2 -2
View File
@@ -10,13 +10,13 @@ match some_option {
Some(x) => {
// do something with x
},
None => {},
None => (),
}
```
We want to do something with the `Some` match, but do nothing with the `None`
case. We can do this with an `Option`, but with a more complex enum,
adding `_ => {}` after processing just one variant is a lot of boilerplate code
adding `_ => ()` after processing just one variant is a lot of boilerplate code
that we have to add to satisfy the `match` expression.
Instead, we could write this in a shorter way with `if let`. This code behaves