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

@@ -19,6 +19,3 @@ On top of traits as a concept, we'll also cover some of the key traits that are
Since we'll be talking about conversions, we'll seize the opportunity to plug some of the "knowledge gaps"
from the previous chapter—e.g. what is `"A title"`, exactly? Time to learn more about slices too!
## References
- The exercise for this section is located in `exercises/04_traits/00_intro`

View File

@@ -124,8 +124,4 @@ This is not necessary if:
You can find the list of traits and types in the prelude in the
[Rust documentation](https://doc.rust-lang.org/std/prelude/index.html).
## References
- The exercise for this section is located in `exercises/04_traits/01_trait`
[^inherent]: A method defined directly on a type, without using a trait, is also known as an **inherent method**.

View File

@@ -105,10 +105,6 @@ Which implementation should be used? The one defined in `B`? Or the one defined
There's no good answer, therefore the orphan rule was defined to prevent this scenario.
Thanks to the orphan rule, neither crate `B` nor crate `C` would compile.
## References
- The exercise for this section is located in `exercises/04_traits/02_orphan_rule`
## Further reading
- There are some caveats and exceptions to the orphan rule as stated above.

View File

@@ -97,6 +97,3 @@ impl PartialEq for MyType {
}
```
## References
- The exercise for this section is located in `exercises/04_traits/03_operator_overloading`

View File

@@ -97,10 +97,6 @@ impl ::core::cmp::PartialEq for Ticket {
The compiler will nudge you to derive traits when possible.
## References
- The exercise for this section is located in `exercises/04_traits/04_derive`
## Further reading
- [The little book of Rust macros](https://veykril.github.io/tlborm/)

View File

@@ -171,6 +171,3 @@ each function signature is a contract between the caller and the callee, and the
This allows for better error messages, better documentation, less unintentional breakages across versions,
and faster compilation times.
## References
- The exercise for this section is located in `exercises/04_traits/05_trait_bounds`

View File

@@ -115,6 +115,3 @@ If a method returns a `&String`, you're promising that there is heap-allocated U
If a method returns a `&str`, instead, you have a lot more freedom: you're just saying that _somewhere_ there's a
bunch of text data and that a subset of it matches what you need, therefore you're returning a reference to it.
## References
- The exercise for this section is located in `exercises/04_traits/06_str_slice`

View File

@@ -90,6 +90,3 @@ is defined on both `T` and `U`, which one will be called?
We'll examine later in the course the "safest" use cases for deref coercion: smart pointers.
## References
- The exercise for this section is located in `exercises/04_traits/07_deref`

View File

@@ -78,6 +78,3 @@ All the types we've seen so far are `Sized`: `u32`, `String`, `bool`, etc.
`&str` is `Sized` though! We know its size at compile time: two `usize`s, one for the pointer
and one for the length.
## References
- The exercise for this section is located in `exercises/04_traits/08_sized`

View File

@@ -139,6 +139,3 @@ In most cases, the target type is either:
`.into()` will work out of the box as long as the compiler can infer the target type from the context without ambiguity.
## References
- The exercise for this section is located in `exercises/04_traits/09_from`

View File

@@ -141,10 +141,6 @@ To recap:
- Use a **generic parameter** when you want to allow multiple implementations of the trait for the same type,
with different input types.
## References
- The exercise for this section is located in `exercises/04_traits/10_assoc_vs_generic`
[^flexible]: Flexibility is rarely free: the trait definition is more complex due to `Output`, and implementors have to reason about
what they want to return. The trade-off is only justified if that flexibility is actually needed. Keep that in mind
when designing your own traits.

View File

@@ -106,6 +106,3 @@ The compiler implements `Clone` for `MyType` as you would expect: it clones each
then constructs a new `MyType` instance using the cloned fields.\
Remember that you can use `cargo expand` (or your IDE) to explore the code generated by `derive` macros.
## References
- The exercise for this section is located in `exercises/04_traits/11_clone`

View File

@@ -112,6 +112,3 @@ struct MyStruct {
}
```
## References
- The exercise for this section is located in `exercises/04_traits/12_copy`

View File

@@ -51,6 +51,3 @@ error[E0184]: the trait `Copy` cannot be implemented for this type; the type has
| ^^^^ `Copy` not allowed on types with destructors
```
## References
- The exercise for this section is located in `exercises/04_traits/13_drop`

View File

@@ -26,6 +26,3 @@ A few guidelines to keep in mind:
Before moving on, let's go through one last exercise to consolidate what we've learned.
You'll have minimal guidance this time—just the exercise description and the tests to guide you.
## References
- The exercise for this section is located in `exercises/04_traits/14_outro`