forked from rust-lang/book
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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.
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.
Upgrade to Rust 1.81
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) <[email protected]> Co-authored-by: James Munns <[email protected]> Co-authored-by: Tim McNamara <[email protected]>
Co-authored-by: James Munns <[email protected]>
Co-authored-by: Tim McNamara <[email protected]> Co-authored-by: Carol (Nichols || Goulding) <[email protected]>
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.