1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-06-15 05:40:30 +02:00
Commit Graph

43 Commits

Author SHA1 Message Date
83b31e19af cargo: bump the patch group with 2 updates (#2099)
Bumps the patch group with 2 updates:
[serde](https://github.com/serde-rs/serde) and
[tokio-websockets](https://github.com/Gelbpunkt/tokio-websockets).

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-28 10:26:34 +01:00
82b60f27a0 cargo: bump the patch group with 4 updates (#2087)
Bumps the patch group with 4 updates:
[anyhow](https://github.com/dtolnay/anyhow),
[mdbook](https://github.com/rust-lang/mdBook),
[serde](https://github.com/serde-rs/serde) and
[thiserror](https://github.com/dtolnay/thiserror).

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-20 10:06:01 +01:00
a1d43bc74b cargo: bump the patch group with 7 updates (#2077)
Bumps the patch group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.82` | `1.0.83` |
| [serde](https://github.com/serde-rs/serde) | `1.0.200` | `1.0.201` |
| [serde_json](https://github.com/serde-rs/json) | `1.0.116` | `1.0.117`
|
| [zerocopy](https://github.com/google/zerocopy) | `0.7.33` | `0.7.34` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.59` |
`1.0.60` |
| [cxx](https://github.com/dtolnay/cxx) | `1.0.121` | `1.0.122` |
| [cxx-build](https://github.com/dtolnay/cxx) | `1.0.121` | `1.0.122` |

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-13 10:28:26 +01:00
5ff3b65ea9 Fix broken link to unsafe-traits.md (#2064)
I came upon a broken link which takes you to (Document Not Found):
https://google.github.io/comprehensive-rust/concurrency/unsafe/unsafe-traits.html

Verified locally with `mdbook serve` and now it links correctly
2024-05-07 13:22:39 -04:00
face5af783 Update Concurrency course with times (#2007)
As I mentioned in #1536:

* Break into segments at approximately the places @fw-immunant put
breaks
 * Move all of the files into `src/concurrency`
 * Add timings and segment/session metadata so course outlines appear

There's room for more work here, including some additional feedback from
@fw-immunant after the session I observed, but let's do one step at a
time :)
2024-04-23 13:26:41 +00:00
6b3eb83bff Move mpsc::Sender to the list of Send + Sync types (#1930)
As of 1.72.0, `mpsc::Sender` [is
`Sync`](https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html#impl-Sync-for-Sender%3CT%3E).
2024-03-22 10:27:11 -04:00
4b27e28e7f Update bounded.md (#1919)
Shouldn't it be `recv` instead of `read`? I don't see a `read` function
in Receiver.
2024-03-12 20:48:54 +00:00
976f6f6f24 concurrency: Add detailed teaching notes for welcome and threads slides (#1885)
These follow the flow of what I actually teach, which spends a
significant amount of time on the latter slide. I think it's worthwhile
to have a real flow documented in the teaching notes, both to make sure
nothing gets forgotten and to structure the experience of teaching.
2024-03-06 21:11:52 +00:00
73068d2af2 Improve interior mutability slide (#1683)
Mutex is probably more broadly understood by people coming from other
languages.

Fixes #1512.
2024-01-17 08:53:05 -05:00
c9f66fd425 Format all Markdown files with dprint (#1157)
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 dprint/check#11 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
aebb0bc856 Replace hyphens (-) with em-dashes () (#1500)
The new Chromium class likes — like me! — to use dashes in the writing!
However, I believe it should use an em-dash instead of the hyphen.

Luckily this is easy: we have enabled “typographic quotes” in `mdbook`,
which also handles the conversion of `---` to `—` in the generated HTML.
So I normalized the single existing em-dash to a triple-dash to make it
more consistent (and hopefully make it easier for translators to
consistently enter these characters).
2023-11-28 19:41:09 +01:00
a0bb5f30d0 Add trait bound to example for MutexGuard that is !Send + Sync (#1358)
This example only makes sense (and is therefore easier to understand
logically :) ) if T is Sync. See
https://github.com/rust-lang/rust/issues/41622 - this used to be a bug
initially.
2023-10-12 22:29:37 +02:00
c93a4bc20c Remove unused import (use) (#1303)
This should be a clean pull request with just the required diff
2023-10-05 11:17:48 +02:00
2072ed022b Fix typo (missing s on threads) (#1304)
Again, a clean pull request for this typo.
2023-10-05 09:17:17 +00:00
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
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
1ed40f4746 Corrected spelling in bounded.md (#844)
Corrected spellling  bounded.md
2023-06-21 07:12:59 +00:00
cf0ce5c0b2 Explain iff in mutex.md (#810)
---------

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-06-13 12:56:42 +00:00
9cf55893ac Rephrase when send blocks (#792)
* Rephrase when `send` blocks

From a discussion with @hueich in #786: https://github.com/google/comprehensive-rust/pull/786#discussion_r1224850499.
2023-06-11 13:20:33 +00:00
584e3ecd7d Fix inconsistent code in unbounded.md (#656)
Update unbounded.md to address inconsistent code

Fix inconsistency between concurrency `unbounded.md` and `bounded.md` by using implicitly named arguments for both.
2023-05-23 11:36:58 +02:00
d0bf0d7a44 Order Send/Sync before Arc/Mutex (#605)
The Arc/Mutex chapters mention Send/Sync in the speaker notes, and in
fact serve as good illustrations of the traits, so let's define the
traits before referencing them.
2023-05-05 09:50:17 +02:00
b051b04afa Use explicit Arc::clone instead of calling .clone() method (#596)
This is to highlight that the clones are cheap: they run custom logic
in the reference counted type, they don’t do a deep clone.
2023-04-27 23:46:09 +02:00
9ee562c267 Remove unnecessary Mutex::lock from shared state example (#499)
It's not necessary to explicitly take the lock to print it.
2023-03-12 10:48:52 +01:00
916c297d8c Remove explicit typing in Mutex example (#405)
Example contained unnecessary explicit type info for the vector in Mutex v. Rust will magically do the needful conversions for us. Code looks cleaner/simpler without the explicit typing.
2023-02-14 18:40:22 +01:00
c4bc10e31d Inline variables printed with println! and friends (#315)
The course follows the style of inlining variable names where possible
in `println!` statements.
2023-02-09 07:48:18 +01:00
5dd87192e8 Mention that Send and Sync are unsafe traits. 2023-01-27 17:34:31 +00:00
81cf02ffbe Fix typos and details. 2023-01-27 17:34:31 +00:00
cc402a7788 Add some speaker notes to concurrency chapter. 2023-01-27 17:34:31 +00:00
a0a1059c0d Verbose description of Sync-Send relationship
Add a verbose rationale of the statement:
  `T` is `Sync` if and only if `&T` is `Send`
2023-01-26 12:06:54 +00:00
b12a1cb320 Update example.md (#257)
Adding a possible solution to the example that
does not compile. The solution includes notes
with important parts.
2023-01-24 15:25:18 +01:00
7f178d6212 Update mutex.md (#256)
* Update mutex.md

Adding speaker notes why Rust `Mutex` has its design and mentioning briefly `RwLock`.

Someone from the audience can notice `unwrap()` in the code, it might be worth to have the answer in speaker notes.

* Apply suggestions from code review

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 08:43:27 +00:00
178d7104e6 Update channels.md (#254)
* Update channels.md

Adding speaker notes explaining why `send` and `recv` can fail.

* Explicitly mention that the channel is closed when the sender/receiver is dropped

Co-authored-by: Martin Geisler <martin@geisler.net>
2023-01-24 08:35:48 +00:00
dc894b1e9d Update arc.md (#255)
Adding more information about `Arc`: what it stands for, costs and that reference cycles can occur.
2023-01-23 10:57:10 +00:00
8107a0ea2b Update scoped-threads.md (#253)
Adding speaker notes explaining why scoped threads work and what borrowing rules apply.
2023-01-23 10:56:32 +00:00
77a60d4101 Update send-sync.md (#258)
Adding notes that these traits are not to be implemented directly. Yet they are still to be used as normal traits in generic constraints.
2023-01-23 08:51:41 +01:00
e835ee6cdf Add notes to threads.md
From the discussion in #63.
2023-01-09 14:32:04 +01:00
c7eff6b85e Merge pull request #55 from Arthur-Milchior/patch-5
Fix typo on Send+Sync page
2022-12-27 17:19:07 +01:00
4295b8da5c Further refine language as per @QuineDot's idea 2022-12-27 17:17:38 +01:00
cc0c02aa14 Copy-editing on the shared state page
The access is to the specific `T` value found in the `Mutex<T>`.
2022-12-27 17:14:45 +01:00
2b2e006417 Typo
Not sure of the intended meaning. At least the sentence is true and gramattically correct here
2022-12-24 20:39:48 -08:00
94933b43f1 Typos 2022-12-24 20:23:43 -08:00
d752b11694 Minor punctuation update (#11)
* Minor punctuation update

* Update sync.md
2022-12-21 17:41:58 +00:00
c212a473ba Publish Comprehensive Rust 🦀 2022-12-21 16:38:28 +01:00