mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 23:38:41 +08:00
Merge remote-tracking branch 'origin/pr/311'
This commit is contained in:
commit
8614de393b
@ -10,8 +10,8 @@ Chapter 6) concepts are the building blocks for creating new types in your
|
||||
program's domain in order to take full advantage of Rust's compile-time type
|
||||
checking.
|
||||
|
||||
One way of thinking about structs is that they are similar to tuples that we
|
||||
talked about in Chapter 3. Like tuples, the pieces of a struct can be different
|
||||
One way of thinking about structs is that they are similar to tuples, which we
|
||||
talked about in Chapter 3. Like tuples, the pieces of a struct can be of different
|
||||
types. Unlike tuples, we name each piece of data so that it's clearer what the
|
||||
values mean. Structs are more flexible as a result of these names: we don't
|
||||
have to rely on the order of the data to specify or access the values of an
|
||||
|
@ -1,6 +1,6 @@
|
||||
## The `Option` Enum and its Advantages Over Null Values
|
||||
|
||||
In the previous section, we looked at how the `IpAddr` enum lets us use Rust's
|
||||
In the previous section, we looked at how the `IpAddr` enum let us use Rust's
|
||||
type system to encode more information than just the data into our program.
|
||||
This section is a case study of `Option`, which is another enum defined by the
|
||||
standard library. The `Option` type is used in many places because it encodes
|
||||
|
@ -195,7 +195,7 @@ already has the value "hello".
|
||||
|
||||
#### Update a Value Based on the Old Value
|
||||
|
||||
Another common use case for hash maps is to look up a key's value then update
|
||||
Another common use case for hash maps is to look up a key's value and then update
|
||||
it, using the old value. For instance, if we wanted to count how many times
|
||||
each word appeared in some text, we could use a hash map with the words as keys
|
||||
and increment the value to keep track of how many times we've seen that word.
|
||||
|
@ -1,7 +1,7 @@
|
||||
## Workspaces and Multiple Related Crates
|
||||
|
||||
Projects can define a workspace which is a set of crates that will all share
|
||||
the same Cargo.lock and output directory.
|
||||
Projects can define a workspace, which is a set of crates that will all share
|
||||
the same `Cargo.lock` and output directory.
|
||||
|
||||
We weren't technically precise about the difference between a *package* and a
|
||||
*crate* until now, and casually people will use the words *package* and *crate*
|
||||
|
Loading…
Reference in New Issue
Block a user