1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-14 13:01:59 +02:00

21 Commits

Author SHA1 Message Date
Nicole L
04c28ed641
Simplify if-let example ()
I find that `if let` makes the most sense to use when you don't have an
`else` case, otherwise it's generally clearer to express the same thing
with a `match`. This changes the `if let` example to be (arguably) a bit
more idiomatic and less verbose.
2024-04-12 12:45:01 -04:00
Nicole L
c1e605df25
Rework introduction of pattern matching () 2024-02-28 11:14:53 -08:00
Dustin J. Mitchell
9f67c9b0e7
Adjust morning-session timings downward ()
Based on feedback from @marshallpierce that mornings took about 2.5
hours, this adjusts a bunch of the morning times downward to try to
match that. In other words, this is trying to make the times in the
course more accurate, rather than reducing the amount of time available
for these slides.

This also updates the `course-schedule` tool to be able to show
per-segment timings.
2024-02-06 15:48:56 -05:00
Pavel Roskin
14dbc99ed0
Clarify that pattern matching consumes enum variant by default ()
Clarify that pattern matching consumes enum variant by default

Describe two ways to borrow the variant without consuming it.

Fixes .
2024-01-08 10:02:43 +01:00
Martin Geisler
c9f66fd425
Format all Markdown files with dprint ()
This is the result of running `dprint fmt` after removing `src/` from
the list of excluded directories.

This also reformats the Rust code: we might want to tweak this a bit in
the future since some of the changes removes the hand-formatting. Of
course, this formatting can be seen as a mis-feature, so maybe this is
good overall.

Thanks to mdbook-i18n-helpers 0.2, the POT file is nearly unchanged
after this, meaning that all existing translations remain valid! A few
messages were changed because of stray whitespace characters:

     msgid ""
     "Slices always borrow from another object. In this example, `a` has to remain "
    -"'alive' (in scope) for at least as long as our slice. "
    +"'alive' (in scope) for at least as long as our slice."
     msgstr ""

The formatting is enforced in CI and we will have to see how annoying
this is in practice for the many contributors. If it becomes annoying,
we should look into fixing  so that `dprint` can annotate
the lines that need fixing directly, then I think we can consider more
strict formatting checks.

I added more customization to `rustfmt.toml`. This is to better emulate
the dense style used in the course:

- `max_width = 85` allows lines to take up the full width available in
our code blocks (when taking margins and the line numbers into account).
- `wrap_comments = true` ensures that we don't show very long comments
in the code examples. I edited some comments to shorten them and avoid
unnecessary line breaks — please trim other unnecessarily long comments
when you see them! Remember we're writing code for slides 😄
- `use_small_heuristics = "Max"` allows for things like struct literals
and if-statements to take up the full line width configured above.

The formatting settings apply to all our Rust code right now — I think
we could improve this with https://github.com/dprint/dprint/issues/711
which lets us add per-directory `dprint` configuration files. However,
the `inherit: true` setting is not yet implemented (as far as I can
tell), so a nested configuration file will have to copy most or all of
the top-level file.
2023-12-31 00:15:07 +01:00
Dustin J. Mitchell
085cbf2c1e
Update expression-evaluation exercise: more patterns, more enums ()
This modifies the exercise to lean more into interesting `match`
statements. It also uses the standard `Result` type, based on feedback
that students could understand it sufficiently at this point in the
course.

Addresses .
2023-12-14 15:22:28 +00:00
Marshall Pierce
6c5061bb90
Various small fixes ()
Plus one more substantial comment on casting.
2023-12-05 18:06:42 -05:00
Dustin J. Mitchell
6d19292f16
Comprehensive Rust v2 ()
I've taken some work by @fw-immunant and others on the new organization
of the course and condensed it into a form amenable to a text editor and
some computational analysis. You can see the inputs in `course.py` but
the interesting bits are the output: `outline.md` and `slides.md`.

The idea is to break the course into more, smaller segments with
exercises at the ends and breaks in between. So `outline.md` lists the
segments, their duration, and sums those durations up per-day. It shows
we're about an hour too long right now! There are more details of the
segments in `slides.md`, or you can see mostly the same stuff in
`course.py`.

This now contains all of the content from the v1 course, ensuring both
that we've covered everything and that we'll have somewhere to redirect
every page.

Fixes .
Fixes .

---------

Co-authored-by: Nicole LeGare <dlegare.1001@gmail.com>
Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-11-29 16:39:24 +01:00
Dustin J. Mitchell
6744822454
Minor fixes ()
* order the Cat and Dog correctly in the vec

* make example editable

* patterns: capture vs. constant

* clarify notes on indexing a string
2023-04-24 14:46:38 -04:00
Charisee Chiw
59d3d7f625
Indent code in speaker notes ()
* Indent code in speaker notes



* Update stack.md

* Update destructuring-arrays.md

* Update hashmap.md

* Update traits.md
2023-03-11 14:12:32 -08:00
Charisee Chiw
8ee637d886
Lecture notes for Destructing Arrays ()
* Lecture notes for Destructing Arrays

* Update destructuring-arrays.md
2023-02-22 13:41:12 +01:00
Charisee Chiw
cf931075d5
Update destructuring-arrays.md ()
* Update destructuring-arrays.md

* Update destructuring-arrays.md
2023-02-09 13:17:33 -08:00
Marko Zagar
36ce63cb10
Updates and minor fixes to Day 2: Morning () 2023-02-09 21:15:47 +00:00
Charisee Chiw
1835896e58
Speaker notes for destructuring-structs.md ()
* Update destructuring-structs.md

* Update destructuring-structs.md
2023-02-07 07:42:57 +00:00
gendx
c3e3dc6020
Add speaker notes for pattern-matching/destructuring-arrays.md () 2023-02-06 17:38:01 +01:00
Andrew Gaul
f33b1f923a
Use f-string in example for consistency ()
Also fix typo.
2023-02-03 13:07:29 +00:00
Charisee Chiw
4588d95427 Update match-guards.md 2023-01-26 12:08:21 +00:00
Charisee Chiw
bd3642694b
Update destructuring-enums.md ()
* Update destructuring-enums.md

* Update destructuring-enums.md

Following the typesetting and terminology used in https://doc.rust-lang.org/book/ch03-05-control-flow.html and https://doc.rust-lang.org/book/ch06-02-match.html

Co-authored-by: Fabian Bornhofen <fbornhofen@google.com>
2023-01-23 21:20:08 +01:00
Igor Petruk
12c3e2989d
Update match-guards.md ()
* Update match-guards.md

Adding more information how match guards are different from simply using "if" inside of the match case, after the case has matched.

* Be consistent about naming of match arms.

Co-authored-by: Andrew Walbran <qwandor@google.com>
2023-01-23 13:09:32 +00:00
Igor Petruk
94ed176761
Update destructuring-enums.md () 2023-01-23 11:40:02 +00:00
Martin Geisler
c212a473ba Publish Comprehensive Rust 🦀 2022-12-21 16:38:28 +01:00