Skip to content

Commit 3368af2

Browse files
authored
Merge pull request #1088 from passcod/improve-redirects
Improve redirects
2 parents 6e27fb3 + 0ed0eef commit 3368af2

Some content is hidden

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

57 files changed

+1064
-313
lines changed

redirects/associated-types.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
% There is a new edition of the book
1+
% Associated Types
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Associated types are a way of associating a type placeholder with a trait such that the trait method definitions can use these placeholder types in their signatures.
76
8-
* [Related page in the second edition of The Rust Programming Language][2]
7+
```rust
8+
pub trait Iterator {
9+
type Item;
10+
fn next(&mut self) -> Option<Self::Item>;
11+
}
12+
```
13+
14+
---
15+
16+
Here are the relevant sections in the new and old books:
17+
18+
* **[In the second edition: Ch 19.03 — Advanced Traits][2]**
19+
* <small>[In the first edition: Ch 3.30 — Associated Types][1]</small>
920

1021

1122
[1]: first-edition/associated-types.html

redirects/attributes.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
% There is a new edition of the book
1+
% Attributes
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Any item declaration may have an attribute applied to it.
76
8-
* [Index of the second edition of The Rust Programming Language][2]
7+
```rust
8+
// A function marked as a unit test
9+
#[test]
10+
fn test_foo() {
11+
/* ... */
12+
}
13+
```
14+
15+
---
16+
17+
Here are the relevant sections in the new and old books:
18+
19+
* **[In the Rust Reference: Ch 5.3 — Attributes][2]**
20+
* <small>[In the first edition: Ch 3.27 — Attributes][1]</small>
921

1022

1123
[1]: first-edition/attributes.html
12-
[2]: second-edition/index.html
24+
[2]: ../reference/attributes.html

redirects/bibliography.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
% There is a new edition of the book
1+
% Bibliography
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
This page does not exist in [the second edition][2].
6+
You might be interested in a similar page in [the Rust Reference][3].
77

8-
* [Index of the second edition of The Rust Programming Language][2]
8+
* **[In the Rust Reference: Appendix — Influences][3]**
9+
* <small>[In the first edition: Section 7 — Bibliography][1]</small>
910

1011

1112
[1]: first-edition/bibliography.html
1213
[2]: second-edition/index.html
14+
[3]: ../reference/influences.html

redirects/borrow-and-asref.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
% There is a new edition of the book
1+
% Borrow and AsRef
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> A cheap reference-to-reference conversion.
6+
> Used to convert a value to a reference value within generic code.
77
8-
* [Index of the second edition of The Rust Programming Language][2]
8+
```rust
9+
fn is_hello<T: AsRef<str>>(s: T) {
10+
assert_eq!("hello", s.as_ref());
11+
}
12+
```
13+
14+
---
15+
16+
This chapter does not exist in [the second edition][2].
17+
The best place to learn more about this is [the Rust documentation][3].
18+
19+
* **[In the Rust documentation: `convert::AsRef`][3]**
20+
* <small>[In the first edition: Ch 4.10 — Borrow and AsRef][1]</small>
921

1022

1123
[1]: first-edition/borrow-and-asref.html
1224
[2]: second-edition/index.html
25+
[3]: ../std/convert/trait.AsRef.html

redirects/casting-between-types.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
% There is a new edition of the book
1+
% Casting between types
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> A type cast expression is denoted with the binary operator `as`.
6+
> Executing an `as` expression casts the value on the left-hand side to the type on the right-hand side.
77
8-
* [Index of the second edition of The Rust Programming Language][2]
8+
```rust
9+
# fn sum(values: &[f64]) -> f64 { 0.0 }
10+
# fn len(values: &[f64]) -> i32 { 0 }
11+
12+
fn average(values: &[f64]) -> f64 {
13+
let sum: f64 = sum(values);
14+
let size: f64 = len(values) as f64;
15+
sum / size
16+
}
17+
```
18+
19+
---
20+
21+
Here are the relevant sections in the new and old books:
22+
23+
* **[In the second edition: Appendix B — Operators, section Type Cast Expressions][2]**
24+
* [In the Rust Reference: Type Cast Expressions][3]
25+
* [In the Rust documentation: `mem::transmute`][4]
26+
* <small>[In the first edition: Ch 3.29 — Casting between types][1]</small>
927

1028

1129
[1]: first-edition/casting-between-types.html
12-
[2]: second-edition/index.html
30+
[2]: second-edition/appendix-02-operators.html#type-cast-expressions
31+
[3]: ../reference/expressions/operator-expr.html#type-cast-expressions
32+
[4]: ../std/mem/fn.transmute.html

redirects/choosing-your-guarantees.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
% There is a new edition of the book
1+
% Choosing your Guarantees
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Smart pointers are data structures that act like a pointer, but they also have additional metadata and capabilities.
6+
> The different smart pointers defined in Rust’s standard library provide extra functionality beyond what references provide.
77
8-
* [Related chapter in the second edition of The Rust Programming Language][2]
8+
```rust
9+
let b = Box::new(5);
10+
println!("b = {}", b);
11+
```
12+
13+
---
14+
15+
Here are the relevant sections in the new and old books:
16+
17+
* **[In the second edition: Ch 15.00 — Smart Pointers][2]**
18+
* <small>[In the first edition: Ch 4.8 — Choosing your Guarantees][1]</small>
919

1020

1121
[1]: first-edition/choosing-your-guarantees.html

redirects/closures.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
% There is a new edition of the book
1+
% Closures
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Anonymous functions you can save in a variable or pass as arguments to other functions.
76
8-
* [Related page in the second edition of The Rust Programming Language][2]
7+
```rust
8+
# use std::thread;
9+
# use std::time::Duration;
10+
11+
let expensive_closure = |num| {
12+
println!("calculating slowly...");
13+
thread::sleep(Duration::from_secs(2));
14+
num
15+
};
16+
#expensive_closure(5);
17+
```
18+
19+
---
20+
21+
Here are the relevant sections in the new and old books:
22+
23+
* **[In the second edition: Ch 13.01 — Closures][2]**
24+
* <small>[In the first edition: Ch 3.23 — Closures][1]</small>
925

1026

1127
[1]: first-edition/closures.html

redirects/comments.md

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
% There is a new edition of the book
1+
% Comments
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Comments must start with two slashes and continue until the end of the line.
6+
> For comments that extend beyond a single line, you’ll need to include // on each line.
77
8-
* [Related page in the second edition of The Rust Programming Language][2]
8+
```rust
9+
// So we’re doing something complicated here, long enough that we need
10+
// multiple lines of comments to do it! Whew! Hopefully, this comment will
11+
// explain what’s going on.
12+
```
13+
14+
---
15+
16+
Here are the relevant sections in the new and old books:
17+
18+
* **[In the second edition: Ch 3.04 — Comments][2]**
19+
* <small>[In the first edition: Ch 3.4 — Comments][1]</small>
920

1021

1122
[1]: first-edition/comments.html

redirects/compiler-plugins.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
% The Rust Programming Language Has Moved
1+
% Compiler Plugins
22

3-
This chapter of the book has moved to [a chapter in the Unstable
4-
Book][unstable book plugins]. Please check it out there.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
[unstable book plugins]: ../unstable-book/language-features/plugin.html
5+
> Compiler plugins are user-provided libraries that extend the compiler's behavior with new syntax extensions, lint checks, etc.
6+
7+
---
8+
9+
This particular chapter has moved to [the Unstable Book][2].
10+
11+
* **[In the Unstable Rust Book: `plugin`][2]**
12+
* <small><del>[In the first edition: Compiler Plugins][1]</del> (does not exist anymore)</small>
13+
14+
15+
[1]: first-edition/compiler-plugins.html
16+
[2]: ../unstable-book/language-features/plugin.html

redirects/concurrency.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
% There is a new edition of the book
1+
% Concurrency
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Historically, programming [concurrency] has been difficult and error prone: Rust hopes to change that.
6+
> Fearless concurrency allows you to write code that’s free of subtle bugs and is easy to refactor without introducing new bugs.
77
8-
* [Related chapter in the second edition of The Rust Programming Language][2]
8+
---
9+
10+
Here are the relevant sections in the new and old books:
11+
12+
* **[In the second edition: Ch 16.00 — Fearless Concurrency][2]**
13+
* <small>[In the first edition: Ch 4.6 — Concurrency][1]</small>
914

1015

1116
[1]: first-edition/concurrency.html

redirects/conditional-compilation.md

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
% There is a new edition of the book
1+
% Conditional Compilation
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Sometimes one wants to have different compiler outputs from the same code, depending on build target, such as targeted operating system, or to enable release builds.
6+
> Configuration options are either provided by the compiler or passed in on the command line using.
7+
> Rust code then checks for their presence using the `#[cfg(...)]` attribute
78
8-
* [Index of the second edition of The Rust Programming Language][2]
9+
```rust
10+
// The function is only included in the build when compiling for macOS
11+
#[cfg(target_os = "macos")]
12+
fn macos_only() {
13+
// ...
14+
}
15+
```
16+
17+
---
18+
19+
This particular chapter does not exist in [the second edition][2].
20+
The best place to learn about it is [the Rust Reference][3].
21+
22+
* **[In the Rust Reference: Ch 5.3 — Attributes, Conditional Compilation section][3]**
23+
* <small>[In the first edition: Ch 4.3 — Conditional Compilation][1]</small>
924

1025

1126
[1]: first-edition/conditional-compilation.html
12-
[2]: second-edition/index.html
27+
[2]: second-edition/
28+
[3]: ../reference/attributes.html#conditional-compilation

redirects/const-and-static.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
% There is a new edition of the book
1+
% `const` and `static`
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Constants are _always_ immutable, and may only be set to a constant expression, not the result of a function call or any other value that could only be computed at runtime.
6+
>
7+
> Global variables are called `static` in Rust.
78
8-
* [Related section about `const` in the second edition of The Rust Programming Language][2]
9-
* [Related section about `static` in the second edition of The Rust Programming Language][3]
9+
```rust
10+
const MAX_POINTS: u32 = 100_000;
11+
static HELLO_WORLD: &str = "Hello, world!";
12+
```
13+
14+
---
15+
16+
Here are the relevant sections in the new and old books:
17+
18+
* **[In the second edition: Ch 3.01 — Variables and Mutability, section Constants][2]**
19+
* **[In the second edition: Ch 19.01 — Unsafe Rust, section Static Variables][3]**
20+
* <small>[In the first edition: Ch 3.26 — `const` and `static`][1]</small>
1021

1122

1223
[1]: first-edition/const-and-static.html

redirects/crates-and-modules.md

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
% There is a new edition of the book
1+
% Crates and Modules
22

3-
This is an old link. You can [continue to the exact older page][1].
4-
If you're trying to learn Rust, checking out [the second edition][2] might be a better choice.
3+
<small>There is a new edition of the book and this is an old link.</small>
54

6-
* [This page in the first edition of the The Rust Programming Language][1]
5+
> Rust has a module system that enables the reuse of code in an organized fashion.
6+
> A module is a namespace that contains definitions of functions or types, and you can choose whether those definitions are visible outside their module (public) or not (private).
7+
>
8+
> A crate is a project that other people can pull into their projects as a dependency.
79
8-
* [Related chapter about modules in the second edition of The Rust Programming Language][2]
10+
```rust
11+
mod network {
12+
fn connect() {
13+
}
14+
}
15+
```
916

10-
* [Related chapter about crates in the second edition of The Rust Programming Language][3]
17+
---
18+
19+
Here are the relevant sections in the new and old books:
20+
21+
* **[In the second edition: Ch 7.01 — `mod` and the Filesystem][2]**
22+
* [In the second edition: Ch 14.02 — Publishing a Crate to Crates.io][2]
23+
* <small>[In the first edition: Ch 3.25 — Crates and Modules][1]</small>
1124

1225

1326
[1]: first-edition/crates-and-modules.html
14-
[2]: second-edition/ch07-00-modules.html
15-
[3]: second-edition/ch14-00-more-about-cargo.html
27+
[2]: second-edition/ch07-01-mod-and-the-filesystem.html
28+
[3]: second-edition/ch14-02-publishing-to-crates-io.html

0 commit comments

Comments
 (0)