Skip to content

Commit 567bc1d

Browse files
author
Alexis Hunt
committed
Merge branch 'master' of github.com:rust-lang/book
2 parents 5c2d0b7 + 76fa546 commit 567bc1d

File tree

141 files changed

+11089
-12271
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+11089
-12271
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ addons:
1313
- aspell
1414
- aspell-en
1515
before_script:
16-
- (cargo install mdbook --vers 0.0.26 --force || true)
16+
- (cargo install mdbook --vers 0.1.2 --force || true)
1717
script:
1818
- bash ci/build.sh

README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# NOTICE ABOUT STATUS
22

33
The second edition of The Rust Programming Language is getting ever closer to being printed!
4-
This means we're not able to make large changes to chapters that are in any column to the
4+
This means we're not able to make large changes to chapters that are in any column to the
55
right of, and including, the "Frozen" column [on our Project board][proj]. Issues or pull
66
requests submitted for frozen chapters are welcome but will be closed until we start work
77
on a third edition. Thank you!
@@ -12,22 +12,18 @@ on a third edition. Thank you!
1212

1313
[![Build Status](https://travis-ci.org/rust-lang/book.svg?branch=master)](https://travis-ci.org/rust-lang/book)
1414

15-
This repo contains two editions of “The Rust Programming Language”.
15+
This repo contains two editions of “The Rust Programming Language”; we
16+
recommend starting with the second edition.
1617

17-
The second edition is a rewrite that will be printed by NoStarch Press,
18-
available around October 2017.
18+
The second edition is a rewrite that will be printed by No Starch Press,
19+
available around May 2018. Check [the No Starch Page][nostarch] for the latest
20+
information on the release date and how to order.
1921

20-
[You can read the very latest online][html]; the last few chapters aren't completed yet, but
21-
the first half of the book is much improved from the first edition. We recommend
22-
starting with the second edition.
22+
[nostarch]: https://nostarch.com/rust
2323

24-
[html]: http://rust-lang.github.io/book/
25-
26-
Note that links to the standard library won't work in this version; this is intentional
27-
so that links work with the book and API docs shipped with Rust installations for offline
28-
reading. For a version of the book where these links do work, please see the book as shipped
29-
with the latest [stable], [beta], or [nightly] Rust releases. Be aware that issues in those
30-
versions may have been fixed in this repository already.
24+
You can read the book for free online! Please see the book as shipped with the
25+
latest [stable], [beta], or [nightly] Rust releases. Be aware that issues in
26+
those versions may have been fixed in this repository already.
3127

3228
[stable]: https://doc.rust-lang.org/stable/book/second-edition/
3329
[beta]: https://doc.rust-lang.org/beta/book/second-edition/

first-edition/book.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
[book]
12
title = "The Rust Programming Language"
23
author = "The Rust Project Developers"
4+
5+
[output.html]
6+
additional-css = ["src/theme/first-edition.css"]

first-edition/src/const-and-static.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ reference stored in a static has a [`'static` lifetime][lifetimes]:
3838
static NAME: &'static str = "Steve";
3939
```
4040

41+
The type of a `static` value must be `Sync` unless the `static` value is
42+
mutable.
43+
4144
[lifetimes]: lifetimes.html
4245

4346
## Mutability
@@ -64,17 +67,20 @@ unsafe {
6467

6568
[unsafe]: unsafe.html
6669

67-
Furthermore, any type stored in a `static` must be `Sync`, and must not have
68-
a [`Drop`][drop] implementation.
69-
70-
[drop]: drop.html
71-
7270
# Initializing
7371

7472
Both `const` and `static` have requirements for giving them a value. They must
7573
be given a value that’s a constant expression. In other words, you cannot use
7674
the result of a function call or anything similarly complex or at runtime.
7775

76+
# Dropping
77+
78+
Types implementing [`Drop`][drop] are allowed in `const` and `static`
79+
definitions. Constants are inlined where they are used and are dropped
80+
accordingly. `static` values are not dropped.
81+
82+
[drop]: drop.html
83+
7884
# Which construct should I use?
7985

8086
Almost always, if you can choose between the two, choose `const`. It’s pretty

first-edition/src/ffi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ against `libc` and `libm` by default.
570570
In C, functions can be 'variadic', meaning they accept a variable number of arguments. This can
571571
be achieved in Rust by specifying `...` within the argument list of a foreign function declaration:
572572

573-
```no_run
573+
```rust,no_run
574574
extern {
575575
fn foo(x: i32, ...);
576576
}
@@ -584,7 +584,7 @@ fn main() {
584584

585585
Normal Rust functions can *not* be variadic:
586586

587-
```ignore
587+
```rust,ignore
588588
// This will not compile
589589
590590
fn foo(x: i32, ...) { }
@@ -750,7 +750,7 @@ extern "C" {
750750
# fn main() {}
751751
```
752752

753-
By including a private field and no constructor,
753+
By including a private field and no constructor,
754754
we create an opaque type that we can’t instantiate outside of this module.
755755
An empty array is both zero-size and compatible with `#[repr(C)]`.
756756
But because our `Foo` and `Bar` types are

first-edition/src/procedural-macros.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ fn impl_hello_world(ast: &syn::DeriveInput) -> quote::Tokens {
267267
}
268268
}
269269
} else {
270-
//Nope. This is an Enum. We cannot handle these!
271-
panic!("#[derive(HelloWorld)] is only defined for structs, not for enums!");
270+
// Nope. This is an Enum. We cannot handle these!
271+
panic!("#[derive(HelloWorld)] is only defined for structs, not for enums!");
272272
}
273273
}
274274
```

first-edition/src/the-stack-and-the-heap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ like this:
240240
| 1 | y | 42 |
241241
| 0 | x | → (2<sup>30</sup>) - 1 |
242242

243-
We have (2<sup>30</sup>) addresses in our hypothetical computer with 1GB of RAM. And since
243+
We have (2<sup>30</sup>) addresses in our hypothetical computer with 1GiB of RAM. And since
244244
our stack grows from zero, the easiest place to allocate memory is from the
245245
other end. So our first value is at the highest place in memory. And the value
246246
of the struct at `x` has a [raw pointer][rawpointer] to the place we’ve
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.warning {
2+
display: flex;
3+
justify-content: space-between;
4+
align-items: center;
5+
background-color: rgb(242, 222, 222);
6+
border-bottom-color: rgb(238, 211, 215);
7+
border-bottom-left-radius: 4px;
8+
border-bottom-right-radius: 4px;
9+
border-bottom-style: solid;
10+
border-bottom-width: 0.666667px;
11+
border-image-outset: 0 0 0 0;
12+
border-image-repeat: stretch stretch;
13+
border-image-slice: 100% 100% 100% 100%;
14+
border-image-source: none;
15+
border-image-width: 1 1 1 1;
16+
border-left-color: rgb(238, 211, 215);
17+
border-left-style: solid;
18+
border-left-width: 0.666667px;
19+
border-right-color: rgb(238, 211, 215);
20+
border-right-style: solid;
21+
border-right-width: 0.666667px;
22+
border-top-color: rgb(238, 211, 215);
23+
border-top-left-radius: 4px;
24+
border-top-right-radius: 4px;
25+
border-top-style: solid;
26+
border-top-width: 0.666667px;
27+
color: rgb(185, 74, 72);
28+
margin-bottom: 0px;
29+
margin-left: 0px;
30+
margin-right: 0px;
31+
margin-top: 30px;
32+
padding-bottom: 8px;
33+
padding-left: 14px;
34+
padding-right: 35px;
35+
padding-right: 14px;
36+
padding-top: 8px;
37+
}
38+
.warning strong {
39+
color: rgb(185, 74, 72)
40+
}
41+
.warning a {
42+
color: rgb(0, 136, 204)
43+
}
44+
.warning .message {
45+
margin-right: 14px;
46+
}
47+
.warning .message:last-child {
48+
margin-right: 21px;
49+
}
50+
.warning .button {
51+
border: none;
52+
background: none;
53+
color: inherit;
54+
cursor: pointer;
55+
font-size: 14px;
56+
}

first-edition/src/theme/header.hbs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div id="draft-warning" class="warning">
2+
<span class="message">You are reading an <strong>outdated</strong> edition of TRPL. For more, go <a href="../index.html">here</a>.</span>
3+
<button type="button" id="hide-draft-warning" title="Hide draft warning" class="button">
4+
<i class="fa fa-times"></i>
5+
</button>
6+
</div>
7+
<!-- Hide / unhide warning before it is displayed -->
8+
<script type="text/javascript">
9+
var warning = localStorage.getItem('trpl-first-edition-draft-warning');
10+
11+
if (warning === 'hidden') {
12+
Array
13+
.from(document.querySelectorAll('#page-wrapper'))
14+
.forEach(function(block) { block.classList.remove('has-warning'); });
15+
var elem = document.getElementById("draft-warning");
16+
elem.parentNode.removeChild(elem);
17+
}
18+
19+
document.addEventListener("DOMContentLoaded", function(event) {
20+
document.getElementById("hide-draft-warning").addEventListener("click", function(e) {
21+
var elem = document.getElementById("draft-warning");
22+
elem.parentNode.removeChild(elem);
23+
24+
localStorage.setItem('trpl-first-edition-draft-warning', 'hidden');
25+
});
26+
});
27+
</script>

index.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
% The Rust Programming Language
1+
# The Rust Programming Language
22

3-
There are two editions of "The Rust Programming Language":
3+
The current edition of "The Rust Programming Language" is the second
4+
edition, which you can [read here](second-edition/index.html).
45

5-
* [First edition](first-edition/index.html)
6-
* [Second edition](second-edition/index.html)
6+
The source for all editions lives [on GitHub](https://github.com/rust-lang/book).
7+
Please open issues with any questions, concerns, or tweaks.
78

8-
The second edition is a complete re-write. It is still under construction,
9-
though it is far enough along to learn most of Rust. We suggest reading the
10-
second edition and then checking out the first edition later to pick up some of
11-
the more esoteric parts of the language.
9+
## Notes
10+
11+
The second edition is still receiving some minor edits, but is effectively
12+
complete. It will be [available in dead-tree form through NoStarch
13+
Press](https://nostarch.com/Rust) once these final edits are complete.
14+
15+
The second edition is a complete re-write of TRPL, from the ground up,
16+
and is therefore very different from the first edition.
17+
18+
## Other editions
19+
20+
We keep older editions of TRPL online for history's sake.
21+
22+
### First Edition
23+
24+
You can [read the first edition of "The Rust Programming Language"
25+
here](first-edition/index.html).

0 commit comments

Comments
 (0)