Skip to content

Commit 8f85483

Browse files
authored
Merge pull request #11 from rust-lang/master
Merge pull request rust-lang#2350 from rust-lang/steveklabnik-patch-2
2 parents 20043e4 + 1e7000e commit 8f85483

11 files changed

+90
-82
lines changed

.github/workflows/main.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
name: Run tests
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- name: Update rustup
11+
run: rustup self update
12+
- name: Install Rust
13+
run: |
14+
rustup set profile minimal
15+
rustup toolchain install 1.41.0 -c rust-docs
16+
rustup default 1.41.0
17+
- name: Install mdbook
18+
run: |
19+
mkdir bin
20+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.3.5/mdbook-v0.3.5-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
21+
echo "##[add-path]$(pwd)/bin"
22+
- name: Report versions
23+
run: |
24+
rustup --version
25+
rustc -Vv
26+
mdbook --version
27+
- name: Run tests
28+
run: mdbook test
29+
lint:
30+
name: Run lints
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@master
34+
- name: Update rustup
35+
run: rustup self update
36+
- name: Install Rust
37+
run: |
38+
rustup set profile minimal
39+
rustup toolchain install nightly -c rust-docs
40+
rustup default nightly
41+
- name: Install mdbook
42+
run: |
43+
mkdir bin
44+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.3.5/mdbook-v0.3.5-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
45+
echo "##[add-path]$(pwd)/bin"
46+
- name: Report versions
47+
run: |
48+
rustup --version
49+
rustc -Vv
50+
mdbook --version
51+
- name: Spellcheck
52+
run: bash ci/spellcheck.sh list
53+
- name: Lint for local file paths
54+
run: |
55+
mdbook build
56+
cargo run --bin lfp src
57+
- name: Validate references
58+
run: bash ci/validate.sh
59+
- name: Check for broken links
60+
run: |
61+
curl -sSLo linkcheck.sh \
62+
https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
63+
# Cannot use --all here because of the generated redirect pages aren't available.
64+
sh linkcheck.sh book

.travis.yml

-18
This file was deleted.

ADMIN_TASKS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ occasional maintenance tasks.
55

66
## Update the `rustc` version
77

8-
- Change the version number in `.travis.yml`
8+
- Change the version number in `.github/workflows/main.yml`
99
- Change the version number in `rust-toolchain`, which should change the version you're using
1010
locally with `rustup`
1111
- Change the version number in `src/title-page.md`

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The Rust Programming Language
22

3-
[![Build Status](https://travis-ci.com/rust-lang/book.svg?branch=master)](https://travis-ci.com/rust-lang/book)
3+
![Build Status](https://github.com/rust-lang/book/workflows/CI/badge.svg)
44

55
This repository contains the source of "The Rust Programming Language" book.
66

ci/build.sh

-25
This file was deleted.

ci/validate.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
for file in src/*.md ; do
2+
echo Checking references in $file
3+
cargo run --quiet --bin link2print < $file > /dev/null
4+
done

src/ch01-01-installation.md

-18
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@ for your password. If the install is successful, the following line will appear:
3939
Rust is installed now. Great!
4040
```
4141

42-
If you prefer, feel free to download the script and inspect it before running
43-
it.
44-
45-
The installation script automatically adds Rust to your system PATH after your
46-
next login. If you want to start using Rust right away instead of restarting
47-
your terminal, run the following command in your shell to add Rust to your
48-
system PATH manually:
49-
50-
```text
51-
$ source $HOME/.cargo/env
52-
```
53-
54-
Alternatively, you can add the following line to your *~/.bash_profile*:
55-
56-
```text
57-
$ export PATH="$HOME/.cargo/bin:$PATH"
58-
```
59-
6042
Additionally, you’ll need a linker of some kind. It’s likely one is already
6143
installed, but when you try to compile a Rust program and get errors indicating
6244
that a linker could not execute, that means a linker isn’t installed on your

src/ch04-01-what-is-ownership.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ strings.
4242
> All data stored on the stack must have a known, fixed size. Data with an
4343
> unknown size at compile time or a size that might change must be stored on
4444
> the heap instead. The heap is less organized: when you put data on the heap,
45-
> you request a certain amount of space. The operating system finds an empty
45+
> you request a certain amount of space. The memory allocator finds an empty
4646
> spot in the heap that is big enough, marks it as being in use, and returns a
4747
> *pointer*, which is the address of that location. This process is called
4848
> *allocating on the heap* and is sometimes abbreviated as just *allocating*.
@@ -56,9 +56,9 @@ strings.
5656
> you’ve been seated to find you.
5757
>
5858
> Pushing to the stack is faster than allocating on the heap because the
59-
> operating system never has to search for a place to store new data; that
59+
> allocator never has to search for a place to store new data; that
6060
> location is always at the top of the stack. Comparatively, allocating space
61-
> on the heap requires more work, because the operating system must first find
61+
> on the heap requires more work, because the allocator must first find
6262
> a big enough space to hold the data and then perform bookkeeping to prepare
6363
> for the next allocation.
6464
>
@@ -189,8 +189,8 @@ With the `String` type, in order to support a mutable, growable piece of text,
189189
we need to allocate an amount of memory on the heap, unknown at compile time,
190190
to hold the contents. This means:
191191

192-
* The memory must be requested from the operating system at runtime.
193-
* We need a way of returning this memory to the operating system when we’re
192+
* The memory must be requested from the memory allocator at runtime.
193+
* We need a way of returning this memory to the allocator when we’re
194194
done with our `String`.
195195

196196
That first part is done by us: when we call `String::from`, its implementation
@@ -215,7 +215,7 @@ from Listing 4-1 using a `String` instead of a string literal:
215215
```
216216

217217
There is a natural point at which we can return the memory our `String` needs
218-
to the operating system: when `s` goes out of scope. When a variable goes out
218+
to the allocator: when `s` goes out of scope. When a variable goes out
219219
of scope, Rust calls a special function for us. This function is called `drop`,
220220
and it’s where the author of `String` can put the code to return the memory.
221221
Rust calls `drop` automatically at the closing curly bracket.
@@ -271,7 +271,7 @@ holding the value `"hello"` bound to `s1`</span>
271271

272272
The length is how much memory, in bytes, the contents of the `String` is
273273
currently using. The capacity is the total amount of memory, in bytes, that the
274-
`String` has received from the operating system. The difference between length
274+
`String` has received from the allocator. The difference between length
275275
and capacity matters, but not in this context, so for now, it’s fine to ignore
276276
the capacity.
277277

src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Adding `rand` as a dependency in *Cargo.toml* tells Cargo to download the
179179
make `rand` available to our project.
180180

181181
Then, to bring `rand` definitions into the scope of our package, we added a
182-
`use` line starting with the name of the package, `rand`, and listed the items
182+
`use` line starting with the name of the crate, `rand`, and listed the items
183183
we wanted to bring into scope. Recall that in the [“Generating a Random
184184
Number”][rand]<!-- ignore --> section in Chapter 2, we brought the `Rng` trait
185185
into scope and called the `rand::thread_rng` function:
@@ -191,7 +191,7 @@ into scope and called the `rand::thread_rng` function:
191191
Members of the Rust community have made many packages available at
192192
[crates.io](https://crates.io/), and pulling any of them into your package
193193
involves these same steps: listing them in your package’s *Cargo.toml* file and
194-
using `use` to bring items into scope.
194+
using `use` to bring items from their crates into scope.
195195

196196
Note that the standard library (`std`) is also a crate that’s external to our
197197
package. Because the standard library is shipped with the Rust language, we
@@ -208,7 +208,7 @@ crate.
208208

209209
### Using Nested Paths to Clean Up Large `use` Lists
210210

211-
If we’re using multiple items defined in the same package or same module,
211+
If we’re using multiple items defined in the same crate or same module,
212212
listing each item on its own line can take up a lot of vertical space in our
213213
files. For example, these two `use` statements we had in the Guessing Game in
214214
Listing 2-4 bring items from `std` into scope:
@@ -233,7 +233,7 @@ differ, as shown in Listing 7-18.
233233
<span class="caption">Listing 7-18: Specifying a nested path to bring multiple
234234
items with the same prefix into scope</span>
235235

236-
In bigger programs, bringing many items into scope from the same package or
236+
In bigger programs, bringing many items into scope from the same crate or
237237
module using nested paths can reduce the number of separate `use` statements
238238
needed by a lot!
239239

src/ch15-03-drop.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ provide an implementation for the `Drop` trait on any type, and the code you
66
specify can be used to release resources like files or network connections.
77
We’re introducing `Drop` in the context of smart pointers because the
88
functionality of the `Drop` trait is almost always used when implementing a
9-
smart pointer. For example, `Box<T>` customizes `Drop` to deallocate the space
9+
smart pointer. For example, when a `Box<T>` is dropped it will deallocate the space
1010
on the heap that the box points to.
1111

1212
In some languages, the programmer must call code to free memory or resources

src/ch20-01-single-threaded.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,14 @@ for the next time we ask for data. It therefore needs to be `mut` because its
148148
internal state might change; usually, we think of “reading” as not needing
149149
mutation, but in this case we need the `mut` keyword.
150150

151-
Next, we need to actually read from the stream. We do this in two steps: first,
152-
we declare a `buffer` on the stack to hold the data that is read in. We’ve made
153-
the buffer 512 bytes in size, which is big enough to hold the data of a basic
154-
request and sufficient for our purposes in this chapter. If we wanted to handle
155-
requests of an arbitrary size, buffer management would need to be more
156-
complicated; we’ll keep it simple for now. We pass the buffer to `stream.read`,
157-
which will read bytes from the `TcpStream` and put them in the buffer.
151+
Next, we need to actually read from the stream. We do this in two steps:
152+
first, we declare a `buffer` on the stack to hold the data that is read in.
153+
We’ve made the buffer 1024 bytes in size, which is big enough to hold the
154+
data of a basic request and sufficient for our purposes in this chapter. If
155+
we wanted to handle requests of an arbitrary size, buffer management would
156+
need to be more complicated; we’ll keep it simple for now. We pass the buffer
157+
to `stream.read`, which will read bytes from the `TcpStream` and put them in
158+
the buffer.
158159

159160
Second, we convert the bytes in the buffer to a string and print that string.
160161
The `String::from_utf8_lossy` function takes a `&[u8]` and produces a `String`

0 commit comments

Comments
 (0)