- `extern` now requires `unsafe extern`, but in turn allows functions
within it to be marked as `safe`. Add examples to both effects within
the text, and update listing numbers accordingly.
- `#[no_mangle]` now requires `#[unsafe(no_mangle)]`
These are all backwards-compatible, so we can opt the chapter into using
the new rules without issue.
- Add `SAFETY` documentation on the unsafe function and comments on the
unsafe invocation in the code samples.
- Discuss the soundness issues in more depth and explain the idiomatic
use of those `SAFETY` comments.
Note: this requires Rust 1.82.0, and will be easiest to merge after that
version is stabilized in two weeks. Since it is blocked on that anyway,
I am also basing it on top of the listing changes.
This is no longer the first time people see `while let` in the book, so
(a) update the text to mention Chapter 17, and (b) change the example to
show a `Result`-based scenario in addition to the an `Option`-based that
readers saw back in Chapter 17, to make it clear that `while let` is not
limited to working with `Option`.
Add a short new section showing how assignment to a mutable variable
causes an existing *owned* binding to be freed immediately. Create a new
code sample and a new diagram to illustrate the behavior.
Fixes#4001.
- Introduce diagrams into 17.05 to break up the wall of text and make it
easier to visualize.
- Extract the state machine code to make it easier to reference.
- Standardize on `await` instead of `.await` for inline code references.
- Move note about `race` and `select` up to 17.01 since the text now
references it there, and update the text in 17.03 to account for
already having introduced the function.
- Fix up a number of code samples to avoid showing `extern crate trpl;`.
- Rewrite the transition between 17.04 and 17.05 to account for having
restructured the chapter.
- Rework the example code in 17.05 to refer to the `page_title` example
from the rewritten 17.01 instead of the (now-removed) `hello`.
- When discussing the `Future::poll` method, explicitly address the `cx`
parameter: note what it is used for, and then move on.
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.
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!
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.
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.
- 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.
- 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.
- 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 two of the listings because they never stop.
- 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.