refresher on `RAII` and
use the OS File Descriptor example to start
the discussions around RAII
all previous content is for now moved to `_old` for my own
reference, will add the new content based on the agreed upon
new structure next.
This has a lot of detailed and high-quality API advice.
I think it's particularly useful to developers experienced in other
languages, who may default to carrying over design idioms where Rust has
better options.
This PR introduces:
- A new section for the "Idiomatic Rust" learning module
- (The beginning of) the section on newtype patterns
---------
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
Now that there is a `rustup` package, we can take away the scary
language and ask people to install that. This has the advantage that
people get a trusted tool to download the latest Rust compiler.
The point at which the generics segment will be covered has changed
multiple times. After the last change, the 'logger trait' section was
not updated to reflect when it will now be covered. To keep it more
general, I suggest not specifying when it will be covered.
Having taught the course again since the change to use safe-mmio, it
seems worth keeping this as an intermediate step rather than jumping
straight from pointer arithmetic to safe-mmio's abstractions.
A lot of stuff in the standard library makes use of closures, so I think
it makes sense to cover those first so that we can more easily reference
libstd functions like `map` and `filter`.
I've tried removing this trait bound thinking it's unnecessary only to
then be surprised that it breaks type inference. I think that's worth
calling out to students, so I think a speaker note here would be
appropriate.
I think doing the call to `Duration::try_from_secs_f32` in the pattern
match is a bit verbose since the function name is so long. I usually
split this off into a separate variable so that it's easier to see the
pattern match syntax.
According to the error I got from trying out-of-bound index, array
accesses seem to be checked at compile time.
```
Compiling playground v0.0.1 (/playground)
error: this operation will panic at runtime
--> src/main.rs:3:5
|
3 | a[7] = 0;
| ^^^^ index out of bounds: the length is 5 but the index is 7
|
= note: `#[deny(unconditional_panic)]` on by default
error: could not compile `playground` (bin "playground") due to 1 previous error
```
Bumps the patch group with 1 update:
[reqwest](https://github.com/seanmonstar/reqwest).
Updates `reqwest` from 0.12.18 to 0.12.19
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@fw-immunant generated something like this on-the-fly in teaching the
course, and I thought it was great. I think having a _schematic_
understanding of what's going on here helps students through some of the
pitfalls. Particularly, it motivates `Pin`, which is where @fw-immunant
did this derivation.