1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-17 07:11:27 +02:00
Commit Graph

729 Commits

Author SHA1 Message Date
Martin Geisler
d0e0e5c1af
Skip some untranslatable code blocks (#1258)
This builds on the work of @dyoo in
https://github.com/google/mdbook-i18n-helpers/pull/69: by adding a
special `<!-- mdbook-xgettext: skip -->` comment, we can skip the
following code block.

I also modified a few code blocks to remove translatable text: variable
names are not expected to be translated, so it’s fine to have a line
with `println!("foo: {foo}")` in the code block.

This PR removes 36 messages from the POT file. The number of lines drop
by 633 (3%).

Part of #1257.
2023-09-26 17:04:46 +02:00
Matthew
a492b2f1b2
Italic filenames formatted accordingly (#1259)
**Task** Addresses:
https://github.com/google/comprehensive-rust/issues/625
Certain pages in the mdbook that display filenames have inconsistent
styling.

The style we want to follow: [the interop
section](https://google.github.io/comprehensive-rust/android/interoperability/java.html)

The current problem: [the RTC
driver](https://google.github.io/comprehensive-rust/exercises/bare-metal/rtc.html)
excercise page.

--
@mgeisler I checked this feature by looking through every page


![work](https://github.com/google/comprehensive-rust/assets/38759997/8affd0c2-71f2-4708-88f6-f63cf3c24efa)
2023-09-26 15:15:41 +02:00
Andrew Walbran
864bb942c0
Clarify distinction between Drop trait and drop function. (#1255)
This clears up some misleading explanation from #246.
2023-09-26 11:59:16 +01:00
Frances Wingerter
758639174a
Add solution for Health Statistics exercise (#1172) 2023-09-26 09:29:00 +02:00
Martin Geisler
ca424b90e0
Revert "Update boot-library.md" (#1235)
Reverts google/comprehensive-rust#225. We normally include links at the
start of each exercise blocks — but we don't include links in the
individual exercises.

If we want to add such links, we should do it consistently across the
entire course.
2023-09-25 09:39:37 -04:00
Daniel Fernández Núñez
9d21fe159a
Fix bad link in speaker notes Day 2 exercises (#1244) 2023-09-25 07:01:40 +00:00
Martin Geisler
187fc20007
Fix solution for Storing Books exercise (#1237)
As pointed out by @njr0 in #1233, we were making the exercise confusing
by showing people code that cannot work — and then expecting the course
participants to somehow fix this, without setting clear boundaries for
what can and cannot be modified.

This PR should align the exercise with the other exercises in the course
and avoid the “brain teaser” here.

This also has the advantage of having a full working solution, with no
commented code which will bit-rot over time.
2023-09-22 11:22:51 -04:00
Dustin J. Mitchell
c4a821d43d
Add a pattern-matching exercise (#1231)
This adds a second day-1 afternoon exercise, drawn from the v2 work. It
illustrates general use of an enum and also previews `Result`.

Fixes #1228.
2023-09-22 13:36:57 +02:00
Martin Geisler
ddc9ea1fa6
Replace binary_search example with try_into (#1213)
I don't think `binary_search` is the best example of using `Result` — it
should actually use an `Either` type instead.
2023-09-20 15:52:10 +02:00
Igor Petruk
0b8ec0ca3e
Update drop.md (#246)
Adding speaker notes about more details when people might want to call
`drop`.

It is not about a `Drop` trait per-se, but if this is to be mentioned in
the course, this is a reasonable place.

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
Co-authored-by: Martin Geisler <martin@geisler.net>
2023-09-19 10:29:53 +00:00
Qinglin
7d321262c4
Fix link in translations.md (#1220) 2023-09-19 07:30:23 +02:00
Henri Fontana
b666356642
Link incomplete zh-CN and zh-TW in translations.md (#1219)
Co-authored-by: Martin Geisler <martin@geisler.net>
2023-09-18 09:47:27 -07:00
Martin Geisler
3121bff251
Consolidate editor recommendations in main text (#1217)
This streamlines the text about editors by simply mentioning them.
RustRover is mentioned last since it's new and I don't have any
experience with it yet.
2023-09-18 18:37:59 +02:00
Martin Geisler
991c437986
Trim off licenses when showing solutions (#1212)
The licenses end up in the PO files, causing extra unnecessary for work
our translators. We save about 300 lines from each PO file with this.

This also solves another small problem: when a file is included with an
anchor, other anchors are automatically stripped away. This removes some
confusing `// ANCHOR: foo` and `// ANCHOR_END: foo` lines in the
solutions.
2023-09-18 11:56:55 +02:00
Markus Zoppelt
fd0678f38e
Add JetBrains' RustRover IDE as IDE suggestion (#1215)
Since JetBrains [announced RustRover as their new Rust IDE
(preview)](https://www.jetbrains.com/rust/), I updated the details with
a suggestion for RR in `Using Cargo`.
2023-09-18 01:27:42 +00:00
Henri Fontana
c5c3a6bb35
Update translations.md with Spanish translation available (#1202)
#284
2023-09-12 08:59:53 -07:00
Frances Wingerter
d2e0c62303
exercises/day-2/book-library: Fix typo (#1171) 2023-09-12 09:04:08 +02:00
Martin Geisler
5bf99115fe
Update double-free-modern-cpp.md (#1192)
From a discussion in #1122 where I realized that the heading is hard to
translate.

I added a bit of commentary as part of #1083.
2023-09-11 16:38:49 +02:00
Muhammad Mahmood
354f3afa7c
Corrected Luhn's Algorithm Step 3 (#1194)
In the exercise guideline for the Luhn's algorithm (Day 1, Afternoon
exercise), I made a correction to step 3 to provide a more accurate
explanation. Instead of stating that doubling 7 becomes 14, I clarified
that doubling 7 results in 14, and we should sum the individual digits
of 14 to get the correct value of 5.
2023-09-11 14:24:05 +00:00
Jens Reidel
fb95f779d2
Update dependencies in chat-app exercise (#1195)
Hello there 👋 I'm the author of the `tokio-websockets` crate and
today we published version `0.4.0` of the crate, which finally makes the
public API consistent and aligns it with expectations.

`WebsocketStream` now implements the `Stream` trait, so calling `next()`
has to be done via `StreamExt` now. `connect()` returns a tuple of
`(WebsocketStream, Response)`, so that has to be deconstructed now. And
finally, `as_text()` now returns an `Option<&str>` instead of
`Result<&str, Error>`.

And, *very* importantly: The old `WebsocketStream::next` was **not**
cancellation safe, the new `Stream` implementation is. The exercise uses
`select!`, which very well might have caused misbehavior.

Since we also emptied the default features, I've added the very minimal
ones required to compile the exercise.

This is my first contribution here, so feel free to point me to some
things if I'm missing anything. I wasn't really sure what to do about
the translations, I guess I should leave them as is and they'll be
updated by translators in other PRs?

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2023-09-11 10:19:13 -04:00
Kanta Yamaoka (山岡幹太)
619f8be87b
typo: removed duplicate "seconds" after 500ms (#1190)
Hi, this is a very tiny fix: `take 500ms seconds.` -> `take 500ms.`, but
could you merge if it looks okay? Thank you!
2023-09-09 23:13:59 -07:00
Varun Somani
3813d0b6f1
Add test case for invalid non digit cc number (#1182)
Adding this test case to handle case where we have non-numeric cc number
along with a valid cc number. This is discovered when we filter with
is_numeric() instead of !is_whitespace() all test case does pass. To
handle such scenario adding this test case.
2023-09-07 08:30:18 +00:00
Antonio Linhart
11087c8411
Add typos to CI (#1158)
Hi all!

This CL fixes #1093:
* Avoids including current false-positives in the checking of typos
* Excludes localization-related files, as `typos` works with
  English words
* Fixes existing typos caught in the repo

Tested this in CI with a typo and it showed up in the list of actions!

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-09-05 20:21:59 +00:00
c6c7
5e72cf5687
Bump proc-macro2 from 1.0.50 to 1.0.66 in /src/bare-metal/microcontro… (#1160)
…llers/examples

The proc-macro2 dependency at 1.0.50 results in a build error mentioning
an unknown feature `proc_macro_span_shrink` that no longer exists in
nightly. Per https://github.com/rust-lang/rust/issues/113152, updating
proc-macro2 to the latest version fixes the error.

The build error I saw before updating the proc-macro2 dependency was the
following:

```
> cargo build --bin minimal
   Compiling proc-macro2 v1.0.50
   Compiling bare-metal v0.2.5
   Compiling typenum v1.16.0
   Compiling nrf52833-hal v0.14.1
error[E0635]: unknown feature `proc_macro_span_shrink`
  --> /home/chcl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.50/src/lib.rs:92:30
   |
92 |     feature(proc_macro_span, proc_macro_span_shrink)
   |                              ^^^^^^^^^^^^^^^^^^^^^^

   Compiling cortex-m v0.7.7
For more information about this error, try `rustc --explain E0635`.
error: could not compile `proc-macro2` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
```
2023-09-04 11:50:12 +01:00
Martin Geisler
55f6a8428e
Remove memory management comparison (#1049)
This is a follow-up to #998 and the discussion in #1049. The
comparison page is now gone: like @randomPoison said, it feels
redundant and I also mostly skip over it when teaching the class.

I also took out some duplication in the Rust memory management page. I
would be up for simplifying the whole chapter down to one or two
slides as @djmitche suggests: that would leave us with more time for
covering ownership.
2023-09-01 11:32:48 -04:00
Martin Geisler
c6af2a0d37
Mention how long each course day is (#1155)
Most classes run with 2.5 hours for the morning session and 2.5 hours
for the afternoon session.

I have tried running the course as 2 × 2.5 hours and 2 × 3 hours. My
experience was that people ended up getting really worn out after
spending 6 hours in total on Rust (7 hours including a lunch break).
However, the experience varies from group to group, so this is just a
recommendation.
2023-09-01 14:13:37 +01:00
Martin Geisler
91e87e2da7
Explain that Rust Fundamentals == first 3 days (#1156) 2023-09-01 13:43:20 +01:00
Martin Geisler
45133b26a6
Add a link back to the canonical home (#1141)
This is a follow-up to #1140 to further ensure that people can find the
canonical home for the course.
2023-08-31 09:46:22 +02:00
Frances Wingerter
890c46a90c
Fix some exercise location mixups in Day 2 (#1136)
Should supersede #1135, I think.
2023-08-28 18:53:22 +00:00
Martin Geisler
62dcb323aa
Update deep-dive titles in course structure (#1121)
I'm trying to align on these names for the additional material:

- Rust in Android
- Bare-Metal Rust
- Concurrency in Rust

It's not perfectly reflected everywhere, but this brings us a bit closer
to that.
2023-08-25 18:38:21 +02:00
Frances Wingerter
d3a90373b0
Reorder material on first two days (#913)
- Morning of Day 1 still introduces the language and its high-level
goals/value proposition, and starts with the built-in data types Rust
provides, and how you define a function. 
- Afternoon of Day 1 gets a front loading of the basic control flow
structures in Rust but not the more exotic ones.
- The exercises for day 1 afternoon will be the Luhn algorithm (where we
can match on digits and enums such as `Option`.
- Morning of day 2 still has discussion of memory management.

Fixes #510.

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-08-25 17:42:31 +02:00
Martin Geisler
4c73c23a5b
Fix extra indentation in code block (#1119) 2023-08-24 12:00:58 -04:00
Danny Yoo
40b9a1fc2c
Update for-loops.md to remove misleading sentence (#1094)
Drops the comment about usage in the other loop. It's not related to the
focus on copy semantics, and so we want to eliminate that possible
confusion.

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-08-23 14:10:24 +00:00
Danny Yoo
25d4281992
Iterate over array ref instead of array. (#1081)
This revises the example to iterate over `&array` to dodge a few issues.
2023-08-15 12:50:18 +00:00
Vito King
8b873a850d
Fixed Cell link (#1076) 2023-08-14 08:14:05 +02:00
Martin Geisler
7e08c7b157
Mention backwards compatibility (#1068)
This should allow us to keep the version numbers unchanged for a
while.

Fixes #333.
2023-08-13 15:25:25 +02:00
Martin Geisler
cd5705674a
Remove confusing text in variables.md (#1070)
We have not yet talked about copy/move here, so the notes were confusing.

Fixes #519.
2023-08-13 15:24:57 +02:00
Dustin J. Mitchell
e596b80c03
Tweaks from student feedback (#1061)
* help students with the luhn exercise

* mention method-specific types in speaker notes

* Update src/exercises/day-2/luhn.md

Co-authored-by: Martin Geisler <martin@geisler.net>

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-08-11 12:40:05 +00:00
Dustin J. Mitchell
8956fab9bb
Put Ref/Cell on its own slide (#1062) 2023-08-11 08:39:30 -04:00
Martin Geisler
debaca9f7f
Add speaker notes for CXX page (#1060)
While we don’t have slides showing how to use the crate (#823), we can
at least explain at a high level what the instructor should focus on
when walking through the tutorial.
2023-08-11 13:00:10 +02:00
sakex
f79e6726cc
Add that the ? operator works with From<Err> (#1059) 2023-08-09 16:48:15 +02:00
Fabian Bornhofen
17c77d398a
Update course length in hello-world.md (#1055)
The fundamentals part is only three days long now
2023-08-07 21:36:54 +02:00
Martin Geisler
c23da457ae
Expand "iff" to "if and only if" (#1051)
There has been a few PRs which wanted to change "iff" to "if". Expanding it should help and avoid math-heavy jargon.
2023-08-04 12:52:36 +01:00
Martin Geisler
c7240f604f
Expand "iff" to "if and only if" in pl031.rs (#1052)
* Expand "if" to "if and only if" in pl031.rs

Similar to #1051.
2023-08-04 11:04:02 +01:00
Arman
560cad93e6
Fixed link (#1044) 2023-08-02 15:39:42 +00:00
Martin Geisler
8d9fddd92f
Rename welcome.md to index.md (#1039)
When building the book, mdBook will always generate an `index.html`
page for first page of the book. This meant that we had the same
content available under two different names:

- `welcome.html`: this is what the TOC would link to, and
- `index.html` or simply `/`: this is what search engines link to

Renaming the page and setting up a redirect should fix this confusion.
We still don’t have a good way of avoiding links to the `index.html`
page, but this should fix the first half of the problem.

I tested this for translations as well by building the output in a
subdirectory and serving the parent directory.

Part of #847.
2023-07-28 17:27:31 +02:00
sakex
98be9e149c
Talk about options in ? chapter (#600)
* Talk about options in `?` chapter

* Combine Option and Result examples

* Update try-operator.md

* Remove semicolon from expansion

* Focus on expansion of `expr?`

* Update try-operator.md

* Update try-operator.md

---------

Co-authored-by: Martin Geisler <mgeisler@google.com>
2023-07-28 13:48:58 +02:00
Dominik Maier
a7a9ee84b4
Default trait slides cleanup (#1038)
* Default trait slides cleanup

* Update src/traits/default.md

Co-authored-by: Martin Geisler <martin@geisler.net>

---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-07-27 13:53:47 +00:00
Martin Geisler
785eb7cdf9
Mention Rust Fundamentals on Day 1 welcome (#1034)
Conceptually, I'm now thinking of Day 1 to Day 3 as belonging to "Rust Fundamentals", which together with the deep dives make up what we call "Comprehensive Rust".
2023-07-26 11:11:52 -04:00
sakex
e99df4ae5a
Rephrase static-and-const (#601)
* Rephrase static-and-const

* Reduce size, add table to compare static vs const
2023-07-26 14:15:50 +02:00