From cc6a1ef2614aa94003566027b285b249ccf961fa Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Sun, 23 Jun 2019 20:41:52 -0400 Subject: [PATCH] Fixes made in final layout check --- ...r-referring-to-an-item-in-the-module-tree.md | 5 ++--- ...ing-paths-into-scope-with-the-use-keyword.md | 6 +++--- src/ch09-02-recoverable-errors-with-result.md | 2 +- src/ch11-01-writing-tests.md | 13 +++++++------ src/ch11-03-test-organization.md | 2 +- src/title-page.md | 17 ++++++++--------- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md b/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md index 8cb0dfadc4..ad584b72b4 100644 --- a/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md +++ b/src/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.md @@ -22,9 +22,8 @@ removing some of the modules and functions. We’ll show two ways to call the the crate root. The `eat_at_restaurant` function is part of our library crate’s public API, so we mark it with the `pub` keyword. In the [”Exposing Paths with the `pub` Keyword”][pub] section, we’ll go into more detail -about `pub`. - -Note that this example won’t compile just yet; we’ll explain why in a bit. +about `pub`. Note that this example won’t compile just yet; we’ll explain why +in a bit. Filename: src/lib.rs diff --git a/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md b/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md index 3fcdb4bbe2..af15ace8b4 100644 --- a/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md +++ b/src/ch07-04-bringing-paths-into-scope-with-the-use-keyword.md @@ -291,14 +291,14 @@ crate. If we’re using multiple items defined in the same package or same module, listing each item on its own line can take up a lot of vertical space in our -files. For example, these two `use` statements we had in Listing 2-4 in the -Guessing Game bring items from `std` into scope: +files. For example, these two `use` statements we had in the Guessing Game in +Listing 2-4 bring items from `std` into scope: Filename: src/main.rs ```rust -use std::cmp::Ordering; use std::io; +use std::cmp::Ordering; // ---snip--- ``` diff --git a/src/ch09-02-recoverable-errors-with-result.md b/src/ch09-02-recoverable-errors-with-result.md index 7d666e42e0..85c4192836 100644 --- a/src/ch09-02-recoverable-errors-with-result.md +++ b/src/ch09-02-recoverable-errors-with-result.md @@ -528,7 +528,7 @@ fn main() -> Result<(), Box> { } ``` -The `Box` type is called a *trait object*, which we’ll talk about in +The `Box` type is called a trait object, which we’ll talk about in the [“Using Trait Objects that Allow for Values of Different Types”][trait-objects] section in Chapter 17. For now, you can read `Box` to mean “any kind of error.” Using `?` in a `main` diff --git a/src/ch11-01-writing-tests.md b/src/ch11-01-writing-tests.md index b5c645f34c..42a5391878 100644 --- a/src/ch11-01-writing-tests.md +++ b/src/ch11-01-writing-tests.md @@ -282,11 +282,12 @@ larger rectangle can indeed hold a smaller rectangle Note that we’ve added a new line inside the `tests` module: `use super::*;`. The `tests` module is a regular module that follows the usual visibility rules -we covered in Chapter 7 in the [“Modules as the Privacy -Boundary”][modules-as-privacy-boundary] section. Because the -`tests` module is an inner module, we need to bring the code under test in the -outer module into the scope of the inner module. We use a glob here so anything -we define in the outer module is available to this `tests` module. +we covered in Chapter 7 in the [“Paths for Referring to an Item in the Module +Tree”][paths-for-referring-to-an-item-in-the-module-tree] +section. Because the `tests` module is an inner module, we need to bring the +code under test in the outer module into the scope of the inner module. We use +a glob here so anything we define in the outer module is available to this +`tests` module. We’ve named our test `larger_can_hold_smaller`, and we’ve created the two `Rectangle` instances that we need. Then we called the `assert!` macro and @@ -849,4 +850,4 @@ ch08-02-strings.html#concatenation-with-the--operator-or-the-format-macro ch11-02-running-tests.html#controlling-how-tests-are-run [derivable-traits]: appendix-03-derivable-traits.html [doc-comments]: ch14-02-publishing-to-crates-io.html#documentation-comments-as-tests -[modules-as-privacy-boundary]: ch07-02-defining-modules-to-control-scope-and-privacy.html +[paths-for-referring-to-an-item-in-the-module-tree]: ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html diff --git a/src/ch11-03-test-organization.md b/src/ch11-03-test-organization.md index 56bbccbae4..bc8255e306 100644 --- a/src/ch11-03-test-organization.md +++ b/src/ch11-03-test-organization.md @@ -291,7 +291,7 @@ fn it_adds_two() { ``` Note that the `mod common;` declaration is the same as the module declaration -we demonstrated in Listing 7-25. Then in the test function, we can call the +we demonstrated in Listing 7-21. Then in the test function, we can call the `common::setup()` function. #### Integration Tests for Binary Crates diff --git a/src/title-page.md b/src/title-page.md index 18a664a6b4..bc7fb9031b 100644 --- a/src/title-page.md +++ b/src/title-page.md @@ -2,15 +2,14 @@ *by Steve Klabnik and Carol Nichols, with contributions from the Rust Community* -Welcome to *The Rust Programming Language* book! This version of the text assumes -you’re using Rust 1.31.0 or later with `edition="2018"` in *Cargo.toml* of -all projects to use Rust 2018 Edition idioms. See the [“Installation” section -of Chapter 1][install] to install or update Rust, and see the -new [Appendix E][editions] for information on what editions of -Rust are. +This version of the text assumes you’re using Rust 1.31.0 or later with +`edition="2018"` in *Cargo.toml* of all projects to use Rust 2018 Edition +idioms. See the [“Installation” section of Chapter 1][install] +to install or update Rust, and see the new [Appendix E][editions] for information on editions. The 2018 Edition of the Rust language includes a number of improvements that -make Rust more ergonomic and easier to learn. This printing of the book +make Rust more ergonomic and easier to learn. This iteration of the book contains a number of changes to reflect those improvements: - Chapter 7, “Managing Growing Projects with Packages, Crates, and Modules,” @@ -20,7 +19,7 @@ contains a number of changes to reflect those improvements: Types that Implement Traits” that explain the new `impl Trait` syntax. - Chapter 11 has a new section titled “Using `Result` in Tests” that shows how to write tests that use the `?` operator. -- The “Advanced Lifetimes” section of Chapter 19 was removed because compiler +- The “Advanced Lifetimes” section in Chapter 19 was removed because compiler improvements have made the constructs in that section even rarer. - The previous Appendix D, “Macros,” has been expanded to include procedural macros and was moved to the “Macros” section in Chapter 19. @@ -31,7 +30,7 @@ contains a number of changes to reflect those improvements: - We fixed a number of small errors and imprecise wording throughout the book. Thank you to the readers who reported them! -Note that any code in the first printing of *The Rust Programming Language* +Note that any code in earlier iterations of *The Rust Programming Language* that compiled will continue to compile without `edition="2018"` in the project’s *Cargo.toml*, even as you update the Rust compiler version you’re using. That’s Rust’s backward compatibility guarantees at work!