The content slides all use `fn main`, with the exception of the testing
segment. But with this change, where it makes sense exercises use tests
instead, and not both tests and `fn main`.
A small change in `book.js` supports running tests when a code sample
does not have `fn main` but does have `#[test]`, so these work
naturally.
Fixes#1581.
Change this selector to use the ~= selector to test if a white space
separated word "prev" or "next" is contained
Fixes a speaker notes bug that did not allow going to the next slide in
the speaker notes.
The reason for that is that the "rel" attribute contained "prev"
respective "next prefetch".
See:
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors#attrvalue_2
This fixes part of #2004 when going to the right (containing
"prefetch").
The speaker notes on the borrowck slide are a bit hard to read since
it's a big block of bulleted points. I've reorganized the notes to be a
bit easier to read by making some of the bullet points nested and by
moving some of the points to the "More to Explore" section. I've also
added a note on re-borrowing since students sometimes ask about it, and
I've added some playground links to demonstrate some of the points.
The official playground quite often provides a timeout error as in
https://github.com/google/comprehensive-rust/issues/2549
This is mocking/overriding the response from the playground for success
and failure messages to avoid the server provided timeouts. As far as I
see most responses from the playground are delivered below 10 seconds
(but varies a lot...)
There still might be timeouts and I know of the following knobs that can
be tuned
- wdio waits for 10 seconds until it aborts the current attemp (e.g. to
wait for the text to be as expected)
347de61d13/tests/wdio.conf.ts (L98)
- another timeout is the 15 second timeout for fetching the result from
the playground - this is not overriden by the mock (currently, pending
https://github.com/webdriverio/webdriverio/issues/14090 which would
allow for an immediate mock response without waiting for the remote
endpoint)
347de61d13/theme/book.js (L31)
This approach seems to balance formalism with understanding. That is, it
doesn't mention contravariance, but suggests that lifetime annotations
in parameters and return values mean "opposite" things. It also
leverages the understanding that types must be specified in function
signatures, and are used to check types in the function body and at call
sites.
Move mdbook installation into a script and use exact versions from the
CI.
Update README.md to instruct developers to use the same versions as the
CI to sync both environments.
This is related to #2620 and it fixes#2588
The old slice was doing several things at the same time: demonstrating
both external functions as well as unsafe Rust functions.
We now treat those two topics separately. In addition, the “Calling
Unsafe Functions” heading has become its own slide with a non-crashing
example that shows what can go wrong if an argument is misunderstood
in a call to an unsafe function. The old example didn’t actually
illustrate the danger clearly: it would produce mangled UTF-8 output,
which the Playground server refuses to print.
Part of #2445.
---------
Co-authored-by: Dustin J. Mitchell <djmitche@google.com>
Co-authored-by: Andrew Walbran <qwandor@google.com>
It's generally more idiomatic in Rust to not have trait bounds on the
data type itself. I think we better demonstrate how trait bounds are
used in impl blocks with generic data types in the impl block below the
struct definition. I've also added a speaker note to call this out if
students ask.
Bumps the patch group in /src/bare-metal/aps/examples with 2 updates:
[log](https://github.com/rust-lang/log) and
[cc](https://github.com/rust-lang/cc-rs).
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the patch group in /src/exercises/bare-metal/rtc with 2 updates:
[log](https://github.com/rust-lang/log) and
[cc](https://github.com/rust-lang/cc-rs).
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the minor group in /src/exercises/bare-metal/rtc with 1 update:
[bitflags](https://github.com/bitflags/bitflags).
Updates `bitflags` from 2.6.0 to 2.8.0
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the minor group in /src/bare-metal/aps/examples with 1 update:
[bitflags](https://github.com/bitflags/bitflags).
Updates `bitflags` from 2.6.0 to 2.8.0
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
The "Generic Data Types" slide now uses trait bounds, which makes it
very confusing to explain. (e.g., "ignore this trait bound stuff while I
explain why we need to stutter to describe the generic args on an impl
block").
Also in the "Generic Functions" slide, the speaker notes talks about how
we essentially need to treat the generic args as black boxes - this is
probably more important to address then talking about all the ways you
can make things generic.
I suppose my `svgbob` skills leave a bit to be desired, but I think the
meaning is clear:

Now that I look through the `Rc` implementation, there's a weak count
for every strong count, so the `weak: 0` here is inaccurate. But, maybe
this is too much of an implementation detail? Should I just concentrate
on strong refs? I suppose I could put a `...` in that upper-right box,
to suggest there's more going on here?
This slide had two code samples, neither of which had a `main` and thus
neither of which would run. This removes the first (which is redundant
to one a few slides earlier), adds a `main`, and expands the second to
use a 3-tuple.
When teaching the course, I got a little tripped up thinking students
would need to make the `VerbosityFilter` generic over `Logger`. Let's be
clearer that this is not required, and will be described later.
This also updates the generic-types slide to repeat the exercise,
completing that thought.
In teaching the course, the verbal distinction between "doc" and "dog"
was not clear, so this PR moves away from those symbols.
This also makes the Highlight struct a little more substantial, and
replaces `erase` with a simple call to `drop` to keep the example short.
In teaching the course last week, we broke here, partly due to time
constraints, but partly because this is a pretty mind-bending topic to
tackle at the end of an information-dense day. A break helps, and
spreading the content over a few slides helps as well.
By the timings in the course, this leaves day 2 looking like
*Fundamentals // Day 2 Morning*
_1 hour and 55 minutes: (1 hour and 10 minutes short)_
* Welcome - _3 minutes_
* Pattern Matching - _45 minutes_
* Methods and Traits - _50 minutes_
*Fundamentals // Day 2 Afternoon*
_3 hours and 30 minutes (⏰ *30 minutes too long*)_
* Welcome - _0 minutes_
* Generics - _45 minutes_
* Standard Library Types - _1 hour_
* Standard Library Traits - _1 hour_
* Closures - _20 minutes_
Maybe we should move generics to the morning session?
This is done in the speaker notes as it's a relatively minor point, but
one that students should have in the back of their mind when they
wonder, "hey, how does a `&Foo` match against `Foo` patterns??"