- Reformat everything now that the bug in dprint for wrapping lines with
inline code is fixed.
- Additionally, apply the formatting rules I *should have* applied the
first time, so the repo has the same style it has historically used.
Fix a garden-path expression that can be confusing for those who are familiar with referring to packages using dots, especially when English is a second language for the reader.
- Introduce the concept at the end of 18.2 when discussing the tradeoffs
of dynamic dispatch, with a link to the reference. The link is not
currently valid, because of the versioning timeline, but it will be
when this stabilizes!
- In 18.3, simply replace “object safe” with “dyn compatible”. There is
still probably not enough discussion of it, but with the introduction
and link in 18.2, it is *probably* enough for now?
This appears to still work with pulldown-cmark, but not necessarily in
all renderers, and (more to the point at present) is not compatible with
dprint, which does not like the line wrapping that way!
Multiple people have filed or commented on issues over the past few
years (at least #3782, #4101, #4090, and #3921; and possibly others I
have not found) because seeing “compare” here led them to jump ahead to
the conversion (in the next paragraph). The text was technically correct
as it stood, but since it kept derailing/hijacking people’s train of
thought, tweaking it seems helpful.
The pedantry is accurate, but since we can just drop this entirely, it
will cut the potential distraction for readers who might get hung up on
it otherwise!
Fixes#3818
- `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.
We no longer get the raw pointers from references, although we *could*,
because we can now use the raw pointer operator rather than an `as` cast
and thus can get them directly from a variable in scope.
- 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 does not significantly change the flow or text of the chapter; it
merely acknowledges that we *did* do async and await and refers to the
concepts or suggests the reader think about how things would differ if
using futures and async.
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`.
This restores the work originally done in #3956, which had to be dropped
from that PR because this chapter was blocked on XML handling, which was
resolved in #3975.
Co-authored-by: Bryan Zierk <bryan.zierk@gmail.com>