mirror of https://github.com/rust-lang/book
Fix typos detected by aspell
This commit is contained in:
parent
7836b5fb1f
commit
b77aa4f5db
|
@ -205,7 +205,7 @@ We've been showing a bunch of different possibilities that we could define in
|
|||
our code for storing IP addresses of the two different kinds using an enum. It
|
||||
turns out, though, that wanting to store IP addresses and encode which kind
|
||||
they are is so common that the standard library has a definition we can use!
|
||||
Let's look at how the standard libary defines `IpAddr`: it has the exact enum
|
||||
Let's look at how the standard library defines `IpAddr`: it has the exact enum
|
||||
and variants that we've defined and used, but it chose to embed the address
|
||||
data inside the variants in the form of two different structs, which are
|
||||
defined differently for each variant:
|
||||
|
|
|
@ -708,7 +708,7 @@ Overall, these are the rules for item visibility:
|
|||
|
||||
### Privacy Examples
|
||||
|
||||
Let’s look at a few more examples to get some practice. Create a new libary
|
||||
Let’s look at a few more examples to get some practice. Create a new library
|
||||
project and enter the code in Listing 7-5 into your new project’s `src/lib.rs`:
|
||||
|
||||
Filename: src/lib.rs
|
||||
|
|
|
@ -224,7 +224,7 @@ We've been showing a bunch of different possibilities that we could define in
|
|||
our code for storing IP addresses of the two different kinds using an enum. It
|
||||
turns out, though, that wanting to store IP addresses and encode which kind
|
||||
they are is so common that [the standard library has a definition we can
|
||||
use!][IpAddr]<!-- ignore --> Let's look at how the standard libary defines
|
||||
use!][IpAddr]<!-- ignore --> Let's look at how the standard library defines
|
||||
`IpAddr`: it has the exact enum and variants that we've defined and used, but
|
||||
it chose to embed the address data inside the variants in the form of two
|
||||
different structs, which are defined differently for each variant:
|
||||
|
|
|
@ -215,7 +215,7 @@ Overall, these are the rules for item visibility:
|
|||
|
||||
### Privacy Examples
|
||||
|
||||
Let’s look at a few more examples to get some practice. Create a new libary
|
||||
Let’s look at a few more examples to get some practice. Create a new library
|
||||
project and enter the code in Listing 7-5 into your new project’s *src/lib.rs*:
|
||||
|
||||
<figure>
|
||||
|
|
|
@ -219,7 +219,7 @@ don't think we should repeat it here as well, but we added a reference. /Carol
|
|||
|
||||
If you don't know at the time that you're writing a program the exhaustive set
|
||||
of types the program will get at runtime to store in a vector, the enum
|
||||
technique won't work. Insetad, you can use a trait object, which we'll cover in
|
||||
technique won't work. Instead, you can use a trait object, which we'll cover in
|
||||
Chapter 13.
|
||||
|
||||
Now that we've gone over some of the most common ways to use vectors, be sure
|
||||
|
@ -233,7 +233,7 @@ in the book for space reasons? We might want to justify sending them out of the
|
|||
book if we don't want to cover it here -->
|
||||
|
||||
<!-- Yes, there are many, many methods on Vec: https://doc.rust-lang.org/stable/std/vec/struct.Vec.html
|
||||
Also there are occcasionally new methods available with new versions of the
|
||||
Also there are occasionally new methods available with new versions of the
|
||||
language, so there's no way we can be comprehensive here. We want the reader to
|
||||
use the API documentation in these situations since the purpose of the online
|
||||
docs is to be comprehensive and up to date. I personally wouldn't expect a book
|
||||
|
|
|
@ -95,7 +95,7 @@ in this short program where the error was, it would be nicer if we could have
|
|||
Rust tell us what line in our program caused the error.
|
||||
|
||||
That's what the next line, the `note` is about. If we set the `RUST_BACKTRACE`
|
||||
environment variable, we'll get a backtrace of exactly how the error happend.
|
||||
environment variable, we'll get a backtrace of exactly how the error happened.
|
||||
Let's try that. Listing 9-1 shows the output:
|
||||
|
||||
<figure>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
One of the core tools a programming language gives you is the ability to deal
|
||||
effectively with duplication of code. It's important to minimize the amount of
|
||||
code that is duplicated throughout a program to make maintenace easier and
|
||||
code that is duplicated throughout a program to make maintenance easier and
|
||||
minimize logic errors. Maintenance will be easier if there's only one place
|
||||
that you need to change the code if you change your mind about how the program
|
||||
should work, rather than multiple places in the code. If your program's logic
|
||||
|
|
|
@ -36,7 +36,7 @@ We declare a trait with the `trait` keyword, then the trait's name. In this
|
|||
case, our trait will describe types which can be printed. Inside of curly
|
||||
braces, we declare a method signature, but instead of providing an
|
||||
implementation inside curly braces, we put a semicolon after the signature. A
|
||||
trait can have multiple methods in its body, with the method signatures listend one per line and each line ending in a semicolon.
|
||||
trait can have multiple methods in its body, with the method signatures listened one per line and each line ending in a semicolon.
|
||||
|
||||
Implementing a trait for a particular type looks similar to implementing
|
||||
methods on a type since it's also done with the `impl` keyword, but we specify
|
||||
|
|
|
@ -186,7 +186,7 @@ if left_val == right_val {
|
|||
}
|
||||
```
|
||||
|
||||
Let's take a look at a test that will fail becasue `hello` is not equal to
|
||||
Let's take a look at a test that will fail because `hello` is not equal to
|
||||
`world`. We've also added a custom error message, `greeting operation failed`:
|
||||
|
||||
<span class="filename">Filename: src/lib.rs</span>
|
||||
|
|
|
@ -17,8 +17,8 @@ modifiability. And indeed, it says
|
|||
|
||||
> Indeed, under the implementation strategy we outlined above, in which the
|
||||
> compiler is unaware of threads, it is allowed to transform code subject only
|
||||
> to sequential cor- rectness constraints and hence could generate the code
|
||||
> con- taining a race.
|
||||
> to sequential correctness constraints and hence could generate the code
|
||||
> containing a race.
|
||||
|
||||
However, in Rust, this re-ordering can't happen: Rust won't let you alias x and
|
||||
y between two threads without some sort of synchronization primitive. But this
|
||||
|
|
Loading…
Reference in New Issue