Automatically add exercise links to sections. (#52)

We use an mdbook preprocessor to automatically generate links to the relevant exercise for each section.
We remove all existing manual links and refactor the deploy process to push the rendered book to a branch.
This commit is contained in:
Luca Palmieri
2024-05-24 18:15:38 +02:00
committed by GitHub
parent 99591a715e
commit 1aae615bb4
65 changed files with 1855 additions and 212 deletions

View File

@@ -14,6 +14,3 @@ We'll need to introduce a few more concepts along the way:
- The `TryFrom` and `TryInto` traits, for fallible conversions
- Rust's package system, explaining what's a library, what's a binary, how to use third-party crates
## References
- The exercise for this section is located in `exercises/05_ticket_v2/00_intro`

View File

@@ -42,6 +42,3 @@ enum Status {
`enum`, just like `struct`, defines **a new Rust type**.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/01_enum`

View File

@@ -69,6 +69,3 @@ match status {
The `_` pattern matches anything that wasn't matched by the previous patterns.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/02_match`

View File

@@ -87,6 +87,3 @@ match status {
}
```
## References
- The exercise for this section is located in `exercises/05_ticket_v2/03_variants_with_data`

View File

@@ -65,6 +65,3 @@ Both `if let` and `let/else` are idiomatic Rust constructs.\
Use them as you see fit to improve the readability of your code,
but don't overdo it: `match` is always there when you need it.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/04_if_let`

View File

@@ -73,6 +73,3 @@ assert_eq!(second.2, 8);
Tuples are a convenient way of grouping values together when you can't be bothered to define a dedicated struct type.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/05_nullability`

View File

@@ -82,6 +82,3 @@ That's the big advantage of `Result`: it makes fallibility explicit.
Keep in mind, though, that panics exist. They aren't tracked by the type system, just like exceptions in other languages.
But they're meant for **unrecoverable errors** and should be used sparingly.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/06_fallibility`

View File

@@ -39,6 +39,3 @@ When you call a function that returns a `Result`, you have two key options:
}
```
## References
- The exercise for this section is located in `exercises/05_ticket_v2/07_unwrap`

View File

@@ -37,6 +37,3 @@ match s.parse_u32() {
}
```
## References
- The exercise for this section is located in `exercises/05_ticket_v2/08_error_enums`

View File

@@ -51,6 +51,3 @@ while `Debug` provides a low-level representation that's more suitable to develo
That's why `Debug` can be automatically implemented using the `#[derive(Debug)]` attribute, while `Display`
**requires** a manual implementation.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/09_error_trait`

View File

@@ -62,6 +62,3 @@ binary crate inside. If you want to create a library crate instead, you can use
cargo new my-library --lib
```
## References
- The exercise for this section is located in `exercises/05_ticket_v2/10_packages`

View File

@@ -53,6 +53,3 @@ static_assertions = "1.1.0"
We've been using a few of these throughout the book to shorten our tests.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/11_dependencies`

View File

@@ -40,6 +40,3 @@ In the case of `thiserror`, we have:
- `#[error("{0}")]`: this is the syntax to define a `Display` implementation for each variant of the custom error type.
`{0}` is replaced by the zero-th field of the variant (`String`, in this case) when the error is displayed.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/12_thiserror`

View File

@@ -39,6 +39,3 @@ being attempted.
Just like `From` and `Into`, `TryFrom` and `TryInto` are dual traits.\
If you implement `TryFrom` for a type, you get `TryInto` for free.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/13_try_from`

View File

@@ -149,6 +149,3 @@ You can use the `?` operator to shorten your error handling code significantly.\
In particular, the `?` operator will automatically convert the error type of the fallible operation into the error type
of the function, if a conversion is possible (i.e. if there is a suitable `From` implementation)
## References
- The exercise for this section is located in `exercises/05_ticket_v2/14_source`

View File

@@ -12,10 +12,6 @@ as long as they have a `TicketTitle`, they know it's valid **by construction**.
This is just an example of how you can use Rust's type system to make your code safer and more expressive.
## References
- The exercise for this section is located in `exercises/05_ticket_v2/15_outro`
## Further reading
- [Parse, don't validate](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/)