Skip to content

Commit f388b2a

Browse files
Add CI job to verify that we have no broken links. (mainmatter#50)
Fix all broken links.
1 parent 6d707bb commit f388b2a

File tree

11 files changed

+43
-16
lines changed

11 files changed

+43
-16
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "CI"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-links:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Build book
15+
run: |
16+
cd book
17+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.40/mdbook-v0.4.40-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=.
18+
./mdbook build
19+
- name: Link Checker
20+
uses: lycheeverse/lychee-action@v1
21+
with:
22+
fail: true
23+
args: |
24+
--exclude-loopback
25+
--require-https
26+
--no-progress
27+
book/book

book/src/02_basic_calculator/01_integers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ error[E0308]: mismatched types
117117
|
118118
```
119119

120-
We'll see how to convert between types [later in this course](../04_traits/09_from).
120+
We'll see how to convert between types [later in this course](../04_traits/09_from.md).
121121

122122
## References
123123

@@ -131,8 +131,8 @@ We'll see how to convert between types [later in this course](../04_traits/09_fr
131131

132132
[^traits]: Rust doesn't let you define custom operators, but it puts you in control of how the built-in operators
133133
behave.
134-
We'll talk about operator overloading [later in the course](../04_traits/03_operator_overloading), after we've covered traits.
134+
We'll talk about operator overloading [later in the course](../04_traits/03_operator_overloading.md), after we've covered traits.
135135

136136
[^coercion]: There are some exceptions to this rule, mostly related to references, smart pointers and ergonomics. We'll
137-
cover those [later on](../04_traits/07_deref).
137+
cover those [later on](../04_traits/07_deref.md).
138138
A mental model of "all conversions are explicit" will serve you well in the meantime.

book/src/02_basic_calculator/04_panics.md

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

3-
Let's go back to the `speed` function you wrote for the ["Variables" section](02_variables).
3+
Let's go back to the `speed` function you wrote for the ["Variables" section](02_variables.md).
44
It probably looked something like this:
55

66
```rust
@@ -38,7 +38,7 @@ fn main() {
3838
}
3939
```
4040

41-
There are other mechanisms to work with recoverable errors in Rust, which [we'll cover later](../05_ticket_v2/06_fallibility).
41+
There are other mechanisms to work with recoverable errors in Rust, which [we'll cover later](../05_ticket_v2/06_fallibility.md).
4242
For the time being we'll stick with panics as a brutal but simple stopgap solution.
4343

4444
## References

book/src/02_basic_calculator/10_as_casting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ error: literal out of range for `i8`
8282
As a rule of thumb, be quite careful with `as` casting.
8383
Use it _exclusively_ for going from a smaller type to a larger type.
8484
To convert from a larger to smaller integer type, rely on the
85-
[*fallible* conversion machinery](../05_ticket_v2/13_try_from) that we'll
85+
[*fallible* conversion machinery](../05_ticket_v2/13_try_from.md) that we'll
8686
explore later in the course.
8787

8888
### Limitations
@@ -91,8 +91,8 @@ Surprising behaviour is not the only downside of `as` casting.
9191
It is also fairly limited: you can only rely on `as` casting
9292
for primitive types and a few other special cases.
9393
When working with composite types, you'll have to rely on
94-
different conversion mechanisms ([fallible](../05_ticket_v2/13_try_from)
95-
and [infallible](../04_traits/09_from)), which we'll explore later on.
94+
different conversion mechanisms ([fallible](../05_ticket_v2/13_try_from.md)
95+
and [infallible](../04_traits/09_from.md)), which we'll explore later on.
9696

9797
## References
9898

book/src/03_ticket_v1/05_encapsulation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let ticket = Ticket {
3838
You've seen this in action in the previous exercise on visibility.
3939
We now need to provide one or more public **constructors**—i.e. static methods or functions that can be used
4040
from outside the module to create a new instance of the struct.
41-
Luckily enough we already have one: `Ticket::new`, as implemented in [a previous exercise](02_validation).
41+
Luckily enough we already have one: `Ticket::new`, as implemented in [a previous exercise](02_validation.md).
4242

4343
## Accessor methods
4444

@@ -60,4 +60,4 @@ You have to write them yourself—they're just regular methods.
6060

6161
- The exercise for this section is located in `exercises/03_ticket_v1/05_encapsulation`
6262

63-
[^newtype]: Or refine their type, a technique we'll explore [later on](../05_ticket_v2/15_outro).
63+
[^newtype]: Or refine their type, a technique we'll explore [later on](../05_ticket_v2/15_outro.md).

book/src/03_ticket_v1/10_references_in_memory.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ They just point to a memory location, which _may_ be on the heap, but doesn't ha
4949

5050
- The exercise for this section is located in `exercises/03_ticket_v1/10_references_in_memory`
5151

52-
[^fat]: [Later in the course](../04_traits/06_str_slice) we'll talk about **fat pointers**,
52+
[^fat]: [Later in the course](../04_traits/06_str_slice.md) we'll talk about **fat pointers**,
5353
i.e. pointers with additional metadata. As the name implies, they are larger than
5454
the pointers we discussed in this chapter, also known as **thin pointers**.

book/src/04_traits/05_trait_bounds.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Follow Rust's conventions though: use camel case for type parameter names.
166166

167167
You may wonder why we need trait bounds at all. Can't the compiler infer the required traits from the function's body?
168168
It could, but it won't.
169-
The rationale is the same as for [explicit type annotations on function parameters](../02_basic_calculator/02_variables#function-arguments-are-variables):
169+
The rationale is the same as for [explicit type annotations on function parameters](../02_basic_calculator/02_variables.md#function-arguments-are-variables):
170170
each function signature is a contract between the caller and the callee, and the terms must be explicitly stated.
171171
This allows for better error messages, better documentation, less unintentional breakages across versions,
172172
and faster compilation times.

book/src/04_traits/08_sized.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ From our previous [discussion on memory layouts](../03_ticket_v1/10_references_i
66
it would have been reasonable to expect `&str` to be represented as a single `usize` on
77
the stack, a pointer. That's not the case though. `&str` stores some **metadata** next
88
to the pointer: the length of the slice it points to. Going back to the example from
9-
[a previous section](06_str_slice):
9+
[a previous section](06_str_slice.md):
1010

1111
```rust
1212
let mut s = String::with_capacity(5);

book/src/04_traits/13_drop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The `Drop` trait
22

3-
When we introduced [destructors](../03_ticket_v1/11_destructor),
3+
When we introduced [destructors](../03_ticket_v1/11_destructor.md),
44
we mentioned that the `drop` function:
55

66
1. reclaims the memory occupied by the type (i.e. `std::mem::size_of` bytes)

book/src/05_ticket_v2/01_enum.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Enumerations
22

3-
Based on the validation logic you wrote [in a previous chapter](../03_ticket_v1/02_validation),
3+
Based on the validation logic you wrote [in a previous chapter](../03_ticket_v1/02_validation.md),
44
there are only a few valid statuses for a ticket: `To-Do`, `InProgress` and `Done`.
55
This is not obvious if we look at the `status` field in the `Ticket` struct or at the type of the `status`
66
parameter in the `new` method:

book/src/08_futures/07_cancellation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async fn run() {
102102

103103
- Be extremely careful when using `tokio`'s `select!` macro to "race" two different futures.
104104
Retrying the same task in a loop is dangerous unless you can ensure **cancellation safety**.
105-
Check out [`select!`'s documentation](https://docs.rs/tokio/macro.select.html) for more details.
105+
Check out [`select!`'s documentation](https://tokio.rs/tokio/tutorial/select) for more details.
106106
If you need to interleave two asynchronous streams of data (e.g. a socket and a channel), prefer using
107107
[`StreamExt::merge`](https://docs.rs/tokio-stream/latest/tokio_stream/trait.StreamExt.html#method.merge) instead.
108108
- Rather than "abrupt" cancellation, it can be preferable to rely

0 commit comments

Comments
 (0)