Address steve's comments

This commit is contained in:
Carol (Nichols || Goulding)
2017-09-18 12:57:43 -04:00
parent d7e86a7a91
commit 089474e03d
5 changed files with 24 additions and 24 deletions

View File

@@ -49,17 +49,17 @@ Note that we added a type annotation here. Because we arent inserting any
values into this vector, Rust doesnt know what kind of elements we intend to
store. This is an important point. Vectors are implemented using generics;
well cover how to use generics with your own types in Chapter 10. For now,
know that the `Vec` type provided by the standard library can hold any type,
and when a specific `Vec` holds a specific type, the type is specified within
angle brackets. In Listing 8-1, weve told Rust that the `Vec` in `v` will hold
elements of the `i32` type.
know that the `Vec<T>` type provided by the standard library can hold any type,
and when a specific vector holds a specific type, the type is specified within
angle brackets. In Listing 8-1, weve told Rust that the `Vec<T>` in `v` will
hold elements of the `i32` type.
In more realistic code, Rust can often infer the type of value we want to store
once we insert values, so you rarely need to do this type annotation. Its more
common to create a `Vec` that has initial values, and Rust provides the `vec!`
macro for convenience. The macro will create a new `Vec` that holds the values
we give it. Listing 8-2 creates a new `Vec<i32>` that holds the values `1`,
`2`, and `3`:
common to create a `Vec<T>` that has initial values, and Rust provides the
`vec!` macro for convenience. The macro will create a new vector that holds the
values we give it. Listing 8-2 creates a new `Vec<i32>` that holds the values
`1`, `2`, and `3`:
```rust
let v = vec![1, 2, 3];
@@ -389,7 +389,7 @@ string literal
Because strings are used for so many things, we can use many different generic
APIs for strings, providing us with a lot of options. Some of them can seem
redundant, but they all have their place! In this case, `String::from` and
`.to_string` do the same thing, so which you choose is a matter of style.
`to_string` do the same thing, so which you choose is a matter of style.
Remember that strings are UTF-8 encoded, so we can include any properly encoded
data in them, as shown in Listing 8-12:
@@ -761,12 +761,12 @@ a teams name and the values are each teams score. Given a team name, you c
retrieve its score.
Well go over the basic API of hash maps in this section, but many more goodies
are hiding in the functions defined on `HashMap` by the standard library. As
always, check the standard library documentation for more information.
are hiding in the functions defined on `HashMap<K, V>` by the standard library.
As always, check the standard library documentation for more information.
### Creating a New Hash Map
We can create an empty `HashMap` with `new` and add elements with `insert`. In
We can create an empty hash map with `new` and add elements with `insert`. In
Listing 8-18, were keeping track of the scores of two teams whose names are
Blue and Yellow. The Blue team will start with 10 points, and the Yellow team
starts with 50:

View File

@@ -23,17 +23,17 @@ Note that we added a type annotation here. Because we arent inserting any
values into this vector, Rust doesnt know what kind of elements we intend to
store. This is an important point. Vectors are implemented using generics;
well cover how to use generics with your own types in Chapter 10. For now,
know that the `Vec` type provided by the standard library can hold any type,
and when a specific `Vec` holds a specific type, the type is specified within
angle brackets. In Listing 8-1, weve told Rust that the `Vec` in `v` will hold
elements of the `i32` type.
know that the `Vec<T>` type provided by the standard library can hold any type,
and when a specific vector holds a specific type, the type is specified within
angle brackets. In Listing 8-1, weve told Rust that the `Vec<T>` in `v` will
hold elements of the `i32` type.
In more realistic code, Rust can often infer the type of value we want to store
once we insert values, so you rarely need to do this type annotation. Its more
common to create a `Vec` that has initial values, and Rust provides the `vec!`
macro for convenience. The macro will create a new `Vec` that holds the values
we give it. Listing 8-2 creates a new `Vec<i32>` that holds the values `1`,
`2`, and `3`:
common to create a `Vec<T>` that has initial values, and Rust provides the
`vec!` macro for convenience. The macro will create a new vector that holds the
values we give it. Listing 8-2 creates a new `Vec<i32>` that holds the values
`1`, `2`, and `3`:
```rust
let v = vec![1, 2, 3];

View File

@@ -86,7 +86,7 @@ a `String` from a string literal</span>
Because strings are used for so many things, we can use many different generic
APIs for strings, providing us with a lot of options. Some of them can seem
redundant, but they all have their place! In this case, `String::from` and
`.to_string` do the same thing, so which you choose is a matter of style.
`to_string` do the same thing, so which you choose is a matter of style.
Remember that strings are UTF-8 encoded, so we can include any properly encoded
data in them, as shown in Listing 8-12:

View File

@@ -14,12 +14,12 @@ a teams name and the values are each teams score. Given a team name, you c
retrieve its score.
Well go over the basic API of hash maps in this section, but many more goodies
are hiding in the functions defined on `HashMap` by the standard library. As
always, check the standard library documentation for more information.
are hiding in the functions defined on `HashMap<K, V>` by the standard library.
As always, check the standard library documentation for more information.
### Creating a New Hash Map
We can create an empty `HashMap` with `new` and add elements with `insert`. In
We can create an empty hash map with `new` and add elements with `insert`. In
Listing 8-18, were keeping track of the scores of two teams whose names are
Blue and Yellow. The Blue team will start with 10 points, and the Yellow team
starts with 50: