Skip to content

Commit 0ea16be

Browse files
authored
Merge pull request #3 from rust-lang/master
Update fork
2 parents b3b5bd0 + e8a4714 commit 0ea16be

10 files changed

+89
-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

+1-19
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
@@ -122,7 +104,7 @@ resources include [the Users forum][users] and [Stack Overflow][stackoverflow].
122104

123105
[discord]: https://discord.gg/rust-lang
124106
[users]: https://users.rust-lang.org/
125-
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust
107+
[stackoverflow]: https://stackoverflow.com/questions/tagged/rust
126108

127109
### Local Documentation
128110

src/ch02-00-guessing-game-tutorial.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -650,19 +650,18 @@ cannot compare a string and a number type.
650650

651651
Ultimately, we want to convert the `String` the program reads as input into a
652652
real number type so we can compare it numerically to the secret number. We can
653-
do that by adding the following two lines to the `main` function body:
653+
do that by adding another line to the `main` function body:
654654

655655
<span class="filename">Filename: src/main.rs</span>
656656

657657
```rust,ignore
658658
{{#rustdoc_include ../listings/ch02-guessing-game-tutorial/no-listing-03-convert-string-to-number/src/main.rs:here}}
659659
```
660660

661-
The two new lines are:
661+
The line is:
662662

663663
```rust,ignore
664-
let guess: u32 = guess.trim().parse()
665-
.expect("Please type a number!");
664+
let guess: u32 = guess.trim().parse().expect("Please type a number!");
666665
```
667666

668667
We create a variable named `guess`. But wait, doesn’t the program already have

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/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)