Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to main and add async chapter #206

Merged
merged 558 commits into from
Sep 26, 2024
Merged

Update to main and add async chapter #206

merged 558 commits into from
Sep 26, 2024

Conversation

willcrichton
Copy link
Collaborator

No description provided.

bzierk and others added 30 commits June 12, 2024 13:14
- Tie off the discussion about needing a runtime so that it is clear
  what is needed in `main` and therefore why `main` cannot natively be
  `async` itself.
- Correct the description of what `.await` compiles to.
- Extend the note about the “under the hood” bits: mention generators so
  people know what to go looking for if they are curious.
- Rewrite the existing introduction of the `#[async_main]` macro to lean
  on the material now covered in the previous chapter.
Keep both references, but make the first one a simple definition, and
the second one the “ah, now we can make sense of that definition”.
Re-exporting the macro does not work unless you have `tokio` as a direct
dependency, because its expansion is in terms of Tokio doc-hidden items.
Add some listings which I can actually run, with `TODO` paths in them
since I do not know what the numbers will be, since I have not actually
finished with §0 or §1 yet!
Also rename the files to match their actual titles now that I know them.
Or at least: know a good first pass for them.
- Introduce the relevant supporting features in `trpl`.
- Add a couple listings to show how things do or do not work.
- Incorporate a good discusion of the need to make sure that the `tx`
  in this example gets dropped.
- Add more listings which show borrowing vs. moving a `tx`, covering
  the full territory in that example.
- Add and test more re-exports in `trpl`.

I made a conscious choice here *not* to use `future::join_all()` because
that ends up getting into a discussion of `Pin`. I left a TODO item here
for now because I think it is probably worth getting into, and that
could be a good thing to transition to *after* this section.
It should manage its own dependencies.
Wherever it makes sense to elide these for the sake of clarity, do so!
I am not 100% sure we will keep these, but right now they feel useful for
helping see how `async` can help solve some of these problems.
chriskrycho and others added 29 commits September 11, 2024 07:26
In addition to the baseline changes, skip over non-directory code where
directories are needed to deal with things like `.DS_Store` files. Also
add a bunch of context on error causes from `std::io::Error` because it
was *impossible* to figure out exactly what the source of those were.
Use immutable borrow of `TcpStream` when creating `BufReader`
Add `cargo init` usage suggestion to 1.3
…ctions

Update build instructions: include mdbook plugins
The `block_on` name is what both Tokio and smol use, but it is a bit
obscure from the point of view of introducing this material. `run` says
much more clearly what it does *for the level we care about here*, I
think.
These make up *most* of the rest of the edits I caught while rereading
which are not *major structural revisions*, along with some of the bits
required for those major structural revisions.
This does *not* yet incorporate any of the relevant feedback from Carol
on this, so a couple spots are still pretty messy.
Along with the wording and phrasing-level edits, pull out a fair bit of
material for the “advanced” section at the end, specifically the details
of what `Stream` and `StreamExt` actually do.
Bonus: fix some style guide issues, too!

Co-authored-by: Carol (Nichols || Goulding) <carol.nichols@gmail.com>
Co-authored-by: James Munns <james@onevariable.com>
Co-authored-by: Tim McNamara <paperless@timmcnamara.co.nz>
Co-authored-by: James Munns <james@onevariable.com>
Co-authored-by: Tim McNamara <paperless@timmcnamara.co.nz>
Co-authored-by: Carol (Nichols || Goulding) <carol.nichols@gmail.com>
I accidentally copied these in when pulling in the `trpl-note` mdbook
preprocessor many months ago, and we did not notice amidst the many
other changes in that PR!
Add `reqwest` and `scraper` dependencies to the `trpl` crate. Wrap them
in `trpl` re-exports which keep the API surface low.

Rewrite the whole first section to use `race` along with those `trpl`
re-exports to show a more “real” example of async code right form the
start, including actual concurrency, unlike the previous introduction.

Update 17.03 to account for having introduced `race` already, and update
listing numbers for rewritten 17.01.

The *inclues* for them were fixed already, but not these!
This gets CI working again. The problem was basically a mix of a few
silly mistakes:

- Using `include` instead of `rustdoc_include` in several places.
- Having rewritten the listing numbers incorrectly.
@willcrichton willcrichton merged commit 7341735 into main Sep 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants