Adopt the idiomatic pattern of separating `std` from third-party `use`
statements, with the result that we get the ordering we want for Ch. 07
for “free”.
Fixes#3121
The former phrasing seemed to suggest that we _must not_ annotate types _unless_ there are multiple possibilities.
In fact, we are allowed to add redundant annotations.
Cases where no annotation is needed _despite_ multiple possible types -- e.g. `let n = 8` -- are, presumably, intentionally left out here, so not touching that.
The code as actually written *did* conform to the expetaction of the
text, but only because it was in a `lib.rs` file and so in a module
distinct from the scope directly accessible from `main.rs`; as shown in
the text presentation, however, it was not obvious that it was in a
`lib.rs`, and that detail was elided.
Rename the `lib.rs` to `guessing_game.rs` and declare it as a module in
the `main.rs` file, update the `Listing` to name it, and update the text
to call out the creation of the module.
Previously, when we incorporated Ferris into the container for the
buttons, we were bringing along the visibility of the buttons even when
it was important to know that the code wouldn’t compile. This changes
that by showing and hiding the buttons themselves rather than their
container.
Fixes#4274
This is a trivial thing, but I found the previous “replace a terminal
newline and then count the rest” rather less than obvious. Make the
logic more explicit and, as a fun bonus, skip allocating an extra string
along the way. (Not that it matters, in this case, but it’s always
nice to make that kind of improvement.)
Reading through the Rust Book, I found this code that appears to be
trying to take different actions based on the error type. Looking
closer, I realized that the author changed the code (I believe,
unintentionally) to log only the error type instead of the whole
error when certain conditions are met.
This is a simple fix - the wildcard match for `other_error` is
removed, and replaced with a non-binding wildcard, and the panic
is changed to consuming the base error. This is better because it
changes the minimal amount of functionality in the example code
and it refamiliarizes readers with the wildcard matching system.
"By following the help text’s suggestion, we restrict..." and "...and this example will compile..." imply to the reader that after this paragraph, they can expect to see a corrected code example. This rewording, though somewhat subtle, clarfies how the code example *would* be fixed by following the compiler's help message.
"we'll fix it later in this chapter" somewhat implies that a correct code example will be provided later; "later in this chapter" also implies "quite a bit later", when the fix is actually discussed very shortly after the non-compiling code is presented
Twitter is now X, who knows what 'tweets' are called, and whether *any*
of the current crop of social media platforms will exist by the time the
2027 or 2030 editions of Rust roll around, who knows?
This is a tricky thing to get “just right”, and I am not *totally* happy
with this solution, but I think it’s actually better without the “as a
whole” given the addition of the sentence at the end indicating that its
fields can still be accessed.