Skip to content

Commit ce7f52b

Browse files
authored
Merge pull request #282 from JohnTitor/reorganize-chapters
Reorganize some chapters
2 parents 2e159b0 + ce7f7f8 commit ce7f52b

24 files changed

+106
-96
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ order to write correct Unsafe Rust programs. Due to the nature of this problem,
1919
it may lead to unleashing untold horrors that shatter your psyche into a billion
2020
infinitesimal fragments of despair.
2121

22-
### Requirements
22+
## Requirements
2323

2424
Building the Nomicon requires [mdBook]. To get it:
2525

2626
[mdBook]: https://github.com/rust-lang/mdBook
2727

2828
```bash
29-
$ cargo install mdbook
29+
cargo install mdbook
3030
```
3131

3232
### `mdbook` usage
3333

3434
To build the Nomicon use the `build` sub-command:
3535

3636
```bash
37-
$ mdbook build
37+
mdbook build
3838
```
3939

4040
The output will be placed in the `book` subdirectory. To check it out, open the
@@ -43,13 +43,23 @@ build` and it'll open the index page in your default browser (if the process is
4343
successful) just like with `cargo doc --open`:
4444

4545
```bash
46-
$ mdbook build --open
46+
mdbook build --open
4747
```
4848

4949
There is also a `test` sub-command to test all code samples contained in the book:
5050

5151
```bash
52-
$ mdbook test
52+
mdbook test
53+
```
54+
55+
### `linkcheck`
56+
57+
We use the `linkcheck` tool to find broken links.
58+
To run it locally:
59+
60+
```sh
61+
curl -sSLo linkcheck.sh https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
62+
sh linkcheck.sh --all nomicon
5363
```
5464

5565
## Contributing

book.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,29 @@ description = "The Dark Arts of Advanced and Unsafe Rust Programming"
66
[output.html]
77
git-repository-url = "https://github.com/rust-lang/nomicon"
88

9+
[output.html.redirect]
10+
# Vec-related chapters.
11+
"./vec-alloc.html" = "./vec/vec-alloc.html"
12+
"./vec-dealloc.html" = "./vec/vec-dealloc.html"
13+
"./vec-deref.html" = "./vec/vec-deref.html"
14+
"./vec-drain.html" = "./vec/vec-drain.html"
15+
"./vec-final.html" = "./vec/vec-final.html"
16+
"./vec-insert-remove.html" = "./vec/vec-insert-remove.html"
17+
"./vec-into-iter.html" = "./vec/vec-into-iter.html"
18+
"./vec-layout.html" = "./vec/vec-layout.html"
19+
"./vec-push-pop.html" = "./vec/vec-push-pop.html"
20+
"./vec-raw.html" = "./vec/vec-raw.html"
21+
"./vec-zsts.html" = "./vec/vec-zsts.html"
22+
"./vec.html" = "./vec/vec.html"
23+
24+
# Arc and Mutex related chapters.
25+
"./arc-and-mutex.html" = "./arc-mutex/arc-and-mutex.html"
26+
"./arc-base.html" = "./arc-mutex/arc-base.html"
27+
"./arc-clone.html" = "./arc-mutex/arc-clone.html"
28+
"./arc-drop.html" = "./arc-mutex/arc-drop.html"
29+
"./arc-final.html" = "./arc-mutex/arc-final.html"
30+
"./arc-layout.html" = "./arc-mutex/arc-layout.html"
31+
"./arc.html" = "./arc-mutex/arc.html"
32+
933
[rust]
1034
edition = "2018"

src/README.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/SUMMARY.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Summary
22

3-
[Introduction](README.md)
3+
[Introduction](intro.md)
44

55
* [Meet Safe and Unsafe](meet-safe-and-unsafe.md)
66
* [How Safe and Unsafe Interact](safe-unsafe-meaning.md)
@@ -42,25 +42,25 @@
4242
* [Races](races.md)
4343
* [Send and Sync](send-and-sync.md)
4444
* [Atomics](atomics.md)
45-
* [Implementing Vec](vec.md)
46-
* [Layout](vec-layout.md)
47-
* [Allocating](vec-alloc.md)
48-
* [Push and Pop](vec-push-pop.md)
49-
* [Deallocating](vec-dealloc.md)
50-
* [Deref](vec-deref.md)
51-
* [Insert and Remove](vec-insert-remove.md)
52-
* [IntoIter](vec-into-iter.md)
53-
* [RawVec](vec-raw.md)
54-
* [Drain](vec-drain.md)
55-
* [Handling Zero-Sized Types](vec-zsts.md)
56-
* [Final Code](vec-final.md)
57-
* [Implementing Arc and Mutex](arc-and-mutex.md)
58-
* [Arc](arc.md)
59-
* [Layout](arc-layout.md)
60-
* [Base Code](arc-base.md)
61-
* [Cloning](arc-clone.md)
62-
* [Dropping](arc-drop.md)
63-
* [Final Code](arc-final.md)
45+
* [Implementing Vec](./vec/vec.md)
46+
* [Layout](./vec/vec-layout.md)
47+
* [Allocating](./vec/vec-alloc.md)
48+
* [Push and Pop](./vec/vec-push-pop.md)
49+
* [Deallocating](./vec/vec-dealloc.md)
50+
* [Deref](./vec/vec-deref.md)
51+
* [Insert and Remove](./vec/vec-insert-remove.md)
52+
* [IntoIter](./vec/vec-into-iter.md)
53+
* [RawVec](./vec/vec-raw.md)
54+
* [Drain](./vec/vec-drain.md)
55+
* [Handling Zero-Sized Types](./vec/vec-zsts.md)
56+
* [Final Code](./vec/vec-final.md)
57+
* [Implementing Arc and Mutex](./arc-mutex/arc-and-mutex.md)
58+
* [Arc](./arc-mutex/arc.md)
59+
* [Layout](./arc-mutex/arc-layout.md)
60+
* [Base Code](./arc-mutex/arc-base.md)
61+
* [Cloning](./arc-mutex/arc-clone.md)
62+
* [Dropping](./arc-mutex/arc-drop.md)
63+
* [Final Code](./arc-mutex/arc-final.md)
6464
* [FFI](ffi.md)
6565
* [Beneath `std`](beneath-std.md)
6666
* [#[panic_handler]](panic-handler.md)

src/arc-and-mutex.md renamed to src/arc-mutex/arc-and-mutex.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
Knowing the theory is all fine and good, but the *best* way to understand
44
something is to use it. To better understand atomics and interior mutability,
5-
we'll be implementing versions of the standard library's Arc and Mutex types.
5+
we'll be implementing versions of the standard library's `Arc` and `Mutex` types.
66

7-
TODO: Mutex
7+
TODO: Write `Mutex` chapters.

src/arc-base.md renamed to src/arc-mutex/arc-base.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl<T> Arc<T> {
3434
Since we're building a concurrency primitive, we'll need to be able to send it
3535
across threads. Thus, we can implement the `Send` and `Sync` marker traits. For
3636
more information on these, see [the section on `Send` and
37-
`Sync`](send-and-sync.md).
37+
`Sync`](../send-and-sync.md).
3838

3939
This is okay because:
4040
* You can only get a mutable reference to the value inside an `Arc` if and only

src/arc-clone.md renamed to src/arc-mutex/arc-clone.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ happens-before relationship but is atomic. When `Drop`ping the Arc, however,
2626
we'll need to atomically synchronize when decrementing the reference count. This
2727
is described more in [the section on the `Drop` implementation for
2828
`Arc`](arc-drop.md). For more information on atomic relationships and Relaxed
29-
ordering, see [the section on atomics](atomics.md).
29+
ordering, see [the section on atomics](../atomics.md).
3030

3131
Thus, the code becomes this:
3232

File renamed without changes.
File renamed without changes.

src/arc-layout.md renamed to src/arc-mutex/arc-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ be used where an `Arc<&'a str>` was expected. More importantly, it will give
4141
incorrect ownership information to the drop checker, as it will assume we don't
4242
own any values of type `T`. As this is a structure providing shared ownership of
4343
a value, at some point there will be an instance of this structure that entirely
44-
owns its data. See [the chapter on ownership and lifetimes](ownership.md) for
44+
owns its data. See [the chapter on ownership and lifetimes](../ownership.md) for
4545
all the details on variance and drop check.
4646

4747
To fix the first problem, we can use `NonNull<T>`. Note that `NonNull<T>` is a

0 commit comments

Comments
 (0)