1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-24 15:29:28 +02:00

1168 Commits

Author SHA1 Message Date
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
Andrew Walbran
bc972711a2
Clarify distinction between interior mutability and mutable statics. (#1019) 2023-07-26 13:22:42 +02:00
Martin Geisler
b0a9c630f2
Revert "std::mem::drop is in the prelude" (#1031)
Revert "`std::mem::drop` is in the prelude (#1027)"

This reverts commit 5a8bf5624ddd711ff39ff5f13c3e25ae30098e11.
2023-07-26 10:31:25 +02:00
Martin Geisler
94ff8548fd
Explain what "Android team" means (#1032)
I hope this makes it a little clearer where the course comes from.
2023-07-25 15:21:58 +02:00
Martin Geisler
0980211db2
Introduce Rust Fundamentals on welcome page (#1029)
The split between Day 1 to 3 and the deep dives was never explicitly explained.
2023-07-25 15:04:32 +02:00
Martin Geisler
e9ddf3d9cf
Fix space in welcome.md (#1030) 2023-07-25 12:51:51 +01:00
Martin Geisler
3c7659d59b
Align dining-philosophers-async.rs with sync version (#1024)
* Align dining-philosophers-async.rs with sync version

This updates the version to use `std::mem::swap` like the synchronous version.

* Apply suggestions from code review
2023-07-25 06:56:27 +00:00
Vito King
bf3ffa23ee
Fix self shorthand syntax (#1028)
Fix 'self' shorthand syntax
2023-07-25 08:54:41 +02:00
Martin Geisler
2c820e7bf3
Move thread::spawn to separate function (#1020)
This might make it clearer why the thread cannot borrow from the string.
2023-07-24 14:28:14 -07:00
Martin Geisler
dbb3217667
std::mem::drop is in the prelude (#1026) 2023-07-24 15:03:19 -04:00
Martin Geisler
5a8bf5624d
std::mem::drop is in the prelude (#1027) 2023-07-24 20:46:55 +02:00
Martin Geisler
e8ea741cea
Use Arc::clone instead of .clone() (#1023)
The fully qualified syntax is recommended for `Arc` which implements all methods as associated methods.
2023-07-24 11:19:06 -07:00