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

[WIP] async and .await chapter with all changes #3908

Draft
wants to merge 192 commits into
base: main
Choose a base branch
from

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented Apr 29, 2024

Everything for the new Chapter 17.

Note

Work is actually happening on #3909 and other branches moving into it over time. This PR generally includes everything that #3909 includes, any ongoing edits (e.g. those in #3965, #3983, etc.), and the listings rework—but that last bit means GitHub has a very bad time trying to render the diff. I am maintaining this branch and PR so that I can keep the listings in reasonably good shape as we make changes to src as it stands today, so that when we finally go to merge this thing it is not an extra pile of work all at once.

We will primarily just be re-exporting this, though we may also have a
couple cases where we choose to implement something small around it.
1. Introduce an integration tests crate. Structure it the way people
   *should* for large crates (although this is not that) and document
   why, including linking to a relevant post.
2. Add a basic integration test that verifies the re-export works as it
   should. (This is not exactly rocket science, but we want to make sure
   these things don’t just stop working on accident.)

An open question that remains here: do we want some structure to the
crate beyond the top level re-exports? My inclination at this moment is:
no, because we don’t have any *motivation* for that, and naming things
is difficult. (We cannot do `trpl::async`, for example, because `async`
is a keyword!)
- 17.00: Introduction to the conceptual machinery. This is very nascent
  but has some decent bones.
- 17.01: Trying to get at the foundations for tasks, laziness, etc.;
  this is *especially* incomplete.
- 17.02: Just a paragraph I do not want to lose, which I think *will*
  be useful… eventually.
Add a fair bit more material about the `futures` executor and why we
might prefer to use something else. With that motivation in place, have
the readers add our `trpl` crate. (We can of course rename that crate,
but it does the job for now.) Use it to get the equivalent of
`#[tokio::main]` equivalent and incorporate it into an example.
@carols10cents
Copy link
Member

😬 GitHub is straight up not having a good time rendering the full diff with all the listing changes... so I'm opening a new PR without the listings moving for now 😱

@chriskrycho
Copy link
Contributor Author

😂 Good job, GitHub!

chriskrycho and others added 10 commits July 16, 2024 16:57
htypes! What are htypes? No one will ever know.

Co-authored-by: James Munns <james@onevariable.com>
mdBook does not currently have particularly good support for “external”
crates. To make the test suite work correctly with `trpl`, we must first
build `trpl` itself (`mdbook` will not do it), and then explicitly pass
its `deps` path as a library search path for `mdbook test`. That will
make sure all the crates can be resolved when running the tests.


.github/workflows/main.yml
- Update the contents of the code in the chapter so it is correct, and
  update the text to match. Given this is about `Future`, this may also
  warrant moving/simplifying that whole chunk of code, too.

- Update the listing to use `extern crate` since it does not otherwise
  work correctly with `mdbook test`. Alas.
- Update all the listings in the chapter to use `extern crate` since
  `mdbook test` does not understand Rust 2018. Alas.
- Ignore two of the listings because they never stop.
- Update all the listings in the chapter to use `extern crate` since
  `mdbook test` does not understand Rust 2018. Alas.
- Fix one listing which had gotten out of sync somewhere along the way.
  (This also fixes a comment flagged up by a reviewer!)
- Update all the listings in the chapter to use `extern crate` since
 `mdbook test` does not understand Rust 2018. Alas.
- Ignore a listing which has a missing body apurpose.
- Rewrite the `StreamExt` definition to be more correct, and extract it
  to a standalone “no-listing listing” so we can make sure its
  definition at least type checks.
- Update all the listings in the chapter to use `extern crate` since
 `mdbook test` does not understand Rust 2018. Alas.
- Ignore the listings (inline or otherwise!) which are *intended* not to
  compile, so mdbook does not try to test them.
- Clarify some of the text around the *actual* Tokio definition of the
  `StreamExt::next` method.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 650c74f to e9762af Compare July 17, 2024 21:56
Note: this does *not* include all fixes for the text, only for the links
themselves. For the text, we will also need to search for references to
chapters 17-20. This catches a few of those along the way, but there are
no doubt others.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from e9762af to a25b8db Compare July 22, 2024 18:07
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch 2 times, most recently from 3226441 to 882c3b6 Compare July 22, 2024 18:48
@chriskrycho chriskrycho changed the title [WIP] async and .await chapter with listings updates [WIP] async and .await chapter with all changes Jul 22, 2024
chriskrycho and others added 7 commits July 23, 2024 13:32
Co-authored-by: Tim McNamara <paperless@timmcnamara.co.nz>
Co-authored-by: James Munns <james@onevariable.com>
Co-authored-by: Carol (Nichols || Goulding) <carol.nichols@gmail.com>
Co-authored-by: Will Crichton <crichton.will@gmail.com>
Co-authored-by: Tim McNamara <paperless@timmcnamara.co.nz>
Use the original transitional paragraph and structure, adding to it
instead of rewriting it entirely.

HT @timClicks (Tim McNamara <paperless@timmcnamara.co.nz>) for pointing
out how my rephrasing here made it worse!
- Drop the history lesson and comparisons to other approaches. Focus on
  what async gives us instead.
- Simplify and clarify the 
- Talk about “the network” instead of “network sockets” and simplify the
  example code to match.
- Swap the ordering to match the order in the text (concurrent is first,
  at least for now).
- Make them go left-to-right instead of top-to-bottom for compactness in
  the text.
- Fix rendering issues resulting from the VS Code extension doing things
  that normal `dot` does not, for who knows what reasons.
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from 882c3b6 to de155fe Compare July 31, 2024 13:11
@chriskrycho chriskrycho force-pushed the chriskrycho/chapter-async-await branch from de155fe to ce40557 Compare July 31, 2024 13:24
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.

2 participants