1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-08-08 08:22:52 +02:00
Commit Graph

2410 Commits

Author SHA1 Message Date
2923cf3cae prepare raii chapter for next reviews 2025-08-03 21:33:39 +02:00
42a423764e improve drop bomb code example 2025-08-02 10:59:24 +02:00
4ebb43f663 apply feedback RAII and rewrite; draft 1 2025-08-02 10:34:58 +02:00
9fa819a86c improve RAII intro segment further based on Luca's feedbacl 2025-08-01 21:08:01 +02:00
0baa990306 fix typo 2025-07-27 18:49:33 +02:00
5c2ec8c5b1 further improvements to RAII intro chapter 2025-07-27 18:47:38 +02:00
d804144484 add new RAII intro segment
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.
2025-07-26 21:18:49 +02:00
5a4838ed64 integrate feedback of first reviews (RAII)
- directly where possible
- otherwise as inline feedback as notes to take
  into account for next draft
2025-07-26 15:11:06 +02:00
bb88a79027 fix build (en) step: scopeguard crate import 2025-07-15 20:57:53 +02:00
f4269b7f75 apply dprint fmt 2025-07-15 20:54:50 +02:00
39ae8f65ce initial version of the raii chapters for idiomatic rust 2025-07-15 20:45:54 +02:00
059b44bf35 Update CODEOWNERS (#2817)
I missed the invitation that was discussed in #1999. That's why I was
deleted from here later. I added myself again.
2025-07-13 19:30:25 +00:00
a55ce1d24f Fix typo: "appenix" → "appendix" (#2815)
If I'm not mistaken...
2025-07-13 12:54:05 +00:00
0f41f32be1 Correct a minor mistake in the code in lifetime-elision.md (#2814) 2025-07-10 13:12:46 +00:00
7eecb9bb77 Link to rust-api-guidelines (#2813)
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.
2025-07-09 21:09:08 +02:00
4483602cd2 Introduce 'Idiomatic Rust' learning module (#2800)
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>
2025-07-09 21:03:41 +02:00
c2ffbd7f5b Update cargo.md (#2780)
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.
2025-07-09 18:03:06 +02:00
d4729bfec0 Update exercise.md (#2808)
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.
2025-07-07 16:58:09 -04:00
e35f6d684d Update vec.md (#2810)
With #1898 the slices were moved to day 1. So I deleted the day 3 slice
reference sentence in day 2 vec.md.
2025-07-06 23:01:54 +00:00
8419b3095e A few fixes for the unsafe chapter (#2805)
See individual commits in https://github.com/google/comprehensive-rust/pull/2805. Fixes #2734.
2025-07-05 17:46:42 +00:00
7c23d3bcf8 Provide shorter Cargo aliases for xtool subcommands (#2804)
This change deprecates the use of `cargo xtask <tool>` in favor of
dedicated aliases for each tool.

| Proposed | Current |
|----------|---------|
| `cargo install-tools` |  `cargo xtask install-tools` |
| `cargo web-tests` |  `cargo xtask web-tests` |
| `cargo rust-tests` |  `cargo xtask rust-tests` |
| `cargo serve` |  `cargo xtask serve` |
| `cargo build-book` |  `cargo xtask build` |

_Note_: Because `build` is a pre-existing Cargo sub-command, I've
proposed `cargo build-book` as a strawman.


Fixes #2803
2025-07-05 17:44:47 +00:00
010b443615 cargo: bump the patch group in /src/bare-metal/aps/examples with 3 updates (#2799)
Bumps the patch group in /src/bare-metal/aps/examples with 3 updates:
[aarch64-rt](https://github.com/google/aarch64-rt),
[smccc](https://github.com/google/smccc) and
[zerocopy](https://github.com/google/zerocopy).

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 11:15:41 +01:00
30e3151f56 Bump crate-ci/typos from 1.33.1 to 1.34.0 (#2798)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.33.1 to
1.34.0.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 11:14:56 +01:00
9599e3f7fb Bump dprint/check from 2.2 to 2.3 (#2797)
Bumps [dprint/check](https://github.com/dprint/check) from 2.2 to 2.3.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 11:13:38 +01:00
fb95fb377d cargo: bump the patch group in /src/exercises/bare-metal/rtc with 3 updates (#2796)
Bumps the patch group in /src/exercises/bare-metal/rtc with 3 updates:
[aarch64-rt](https://github.com/google/aarch64-rt),
[smccc](https://github.com/google/smccc) and
[zerocopy](https://github.com/google/zerocopy).

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 11:02:18 +01:00
6194ac4abb cargo: bump the patch group with 4 updates (#2795)
Bumps the patch group with 4 updates:
[clap](https://github.com/clap-rs/clap),
[googletest](https://github.com/google/googletest-rust),
[zerocopy](https://github.com/google/zerocopy) and
[reqwest](https://github.com/seanmonstar/reqwest).

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 11:01:37 +01:00
5e4feff6d7 Add section about UART driver without safe-mmio back in (#2792)
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.
2025-06-30 13:48:32 +01:00
447b31cd45 Remove type annotations from borrowck example (#2791)
These slides are on day 3, I don't think we need the explicit type
annotations at this point.
2025-06-26 15:17:57 -04:00
2e50843812 Move closures section to before libstd sections (#2789)
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`.
2025-06-26 15:17:32 -04:00
c253b33977 Add note about trait bound in closures exercise (#2788)
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.
2025-06-26 15:09:38 -04:00
39d0588c89 Add direct call to talk in trait implementation slide (#2787)
I think it'd be helpful to also show a direct call to `talk`, so that
it's clear that both trait methods can be called directly.
2025-06-26 15:07:50 -04:00
da28a502bf Make pattern matching exercise code editable (#2786)
I swear I already did this one...

@djmitche it looks like you had removed this `editable` after I last
added it, was there some reason for that?
2025-06-26 15:07:18 -04:00
088744a4c2 Split off function call to make pattern match clearer (#2785)
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.
2025-06-26 15:01:46 -04:00
40652b6415 Add note about struct-style enum variants in pattern matching (#2784)
Can't forget to demonstrate struct-style enum variants when talking
about pattern matching.
2025-06-26 15:01:04 -04:00
f51f0dbb13 Fix typo in arrays.md (#2781)
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
```
2025-06-25 21:08:29 +00:00
bb8b35ab74 Add a speaker note about trying to use a variable as a pattern (#2779) 2025-06-18 17:05:32 -07:00
bb1e1c9414 Updates to bare metal day after teaching it again (#2775)
This fixes some issues running some of the examples, and various other
minor issues I found along the way.
2025-06-12 11:27:22 +01:00
ab26027a79 Fix errors in CODEOWNERS as suggested by GH (#2771) 2025-06-03 15:58:44 +00:00
6ba7f2c654 Reduce wdio verbosity (#2768)
This avoids the need to scroll through pages of useless warnings to find
an actual test failure.
2025-06-03 11:47:38 -04:00
74605c345c cargo: bump reqwest from 0.12.18 to 0.12.19 in the patch group (#2770)
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>
2025-06-03 14:46:13 +01:00
3eb9f98f4a Bump crate-ci/typos from 1.32.0 to 1.33.1 (#2769)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.32.0 to
1.33.1.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-06-03 14:45:41 +01:00
0c20fb11f1 Convert dependabot reviewers to CODEOWNERS (#2762)
See
https://github.blog/changelog/2025-04-29-dependabot-reviewers-configuration-option-being-replaced-by-code-owners/.
2025-06-03 14:16:53 +01:00
f9e58d9596 Add a schematic state machine implementing Future (#2048)
@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.
2025-06-03 12:45:22 +00:00
2f37846e44 Bump tar-fs from 3.0.8 to 3.0.9 in /tests in the npm_and_yarn group across 1 directory (#2766)
Bumps the npm_and_yarn group with 1 update in the /tests directory:
[tar-fs](https://github.com/mafintosh/tar-fs).
2025-06-03 08:09:22 -04:00
c1773a7fdb Update some speaker notes for bare metal Rust section (#2764) 2025-06-02 19:16:09 +01:00
64ef712d7d Use safe-mmio crate in PL011 UART driver example and RTC exercise solution (#2752) 2025-06-02 15:28:06 +01:00
f3e369274a Bump crate-ci/typos from 1.31.2 to 1.32.0 (#2761)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.31.2 to
1.32.0.
2025-06-01 20:12:49 -04:00
029c7392a3 cargo: bump bitflags from 2.9.0 to 2.9.1 in /src/bare-metal/aps/examples in the patch group (#2760)
Bumps the patch group in /src/bare-metal/aps/examples with 1 update:
[bitflags](https://github.com/bitflags/bitflags).
2025-06-01 20:12:10 -04:00
53fbe1e71d cargo: bump bitflags from 2.9.0 to 2.9.1 in /src/exercises/bare-metal/rtc in the patch group (#2759)
Bumps the patch group in /src/exercises/bare-metal/rtc with 1 update:
[bitflags](https://github.com/bitflags/bitflags).
2025-06-01 20:06:25 -04:00
1a2081765e cargo: bump the patch group with 4 updates (#2758)
Bumps the patch group with 4 updates:
[clap](https://github.com/clap-rs/clap),
[mdbook](https://github.com/rust-lang/mdBook),
[googletest](https://github.com/google/googletest-rust) and
[reqwest](https://github.com/seanmonstar/reqwest).
2025-06-01 15:30:29 -04:00