diff --git a/nostarch/chapter08.md b/nostarch/chapter08.md index 39a325fb..c44ebd8f 100644 --- a/nostarch/chapter08.md +++ b/nostarch/chapter08.md @@ -1048,6 +1048,7 @@ employee names to a department in a company; for example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let the user retrieve a list of all people in a department or all people in the company by department, sorted alphabetically. + The standard library API documentation describes methods that vectors, strings, and hash maps have that will be helpful for these exercises! diff --git a/nostarch/chapter10.md b/nostarch/chapter10.md index dbe0c906..bb8919d7 100644 --- a/nostarch/chapter10.md +++ b/nostarch/chapter10.md @@ -170,6 +170,7 @@ Listing 10-3: 1. Extract the duplicate code into the body of the function, and specify the inputs and return values of that code in the function signature. 1. Update the two instances of duplicated code to call the function instead. + Next, we’ll use these same steps with generics to reduce code duplication. In the same way that the function body can operate on an abstract `list` instead of specific values, generics allow code to operate on abstract types. diff --git a/nostarch/chapter12.md b/nostarch/chapter12.md index 19aae1ad..86e98617 100644 --- a/nostarch/chapter12.md +++ b/nostarch/chapter12.md @@ -965,6 +965,7 @@ expect. 1. Refactor the code you just added or changed and make sure the tests continue to pass. 1. Repeat from step 1! + Though it’s just one of many ways to write software, TDD can help drive code design. Writing the test before you write the code that makes the test pass helps to maintain high test coverage throughout the process. @@ -1128,6 +1129,7 @@ that and implement `search`, our program needs to follow these steps: 1. If it does, add it to the list of values we’re returning. 1. If it doesn’t, do nothing. 1. Return the list of results that match. + Let’s work through each step, starting with iterating through lines. #### Iterating Through Lines with the lines Method diff --git a/nostarch/chapter16.md b/nostarch/chapter16.md index 7595fa69..7c5389e4 100644 --- a/nostarch/chapter16.md +++ b/nostarch/chapter16.md @@ -821,11 +821,11 @@ mutex is described as *guarding* the data it holds via the locking system. Mutexes have a reputation for being difficult to use because you have to remember two rules: +1. You must attempt to acquire the lock before using the data. +1. When you’re done with the data that the mutex guards, you must unlock the +data so other threads can acquire the lock. -Unmatched: ListNumber0 - -Unmatched: ListNumber0 - For a real-world metaphor for a mutex, imagine a panel discussion at a +For a real-world metaphor for a mutex, imagine a panel discussion at a conference with only one microphone. Before a panelist can speak, they have to ask or signal that they want to use the microphone. When they get the microphone, they can talk for as long as they want to and then hand the diff --git a/nostarch/chapter17.md b/nostarch/chapter17.md index d5bddbbd..946d20a1 100644 --- a/nostarch/chapter17.md +++ b/nostarch/chapter17.md @@ -566,6 +566,7 @@ The final functionality will look like this: 1. When the post is approved, it gets published. 1. Only published blog posts return content to print, so unapproved posts can’t accidentally be published. + Any other changes attempted on a post should have no effect. For example, if we try to approve a draft blog post before we’ve requested a review, the post should remain an unpublished draft. diff --git a/nostarch/chapter19.md b/nostarch/chapter19.md index ec98f2bc..410e7eb6 100644 --- a/nostarch/chapter19.md +++ b/nostarch/chapter19.md @@ -66,6 +66,7 @@ include the ability to: 1. Access or modify a mutable static variable 1. Implement an unsafe trait 1. Access fields of `union`s + It’s important to understand that `unsafe` doesn’t turn off the borrow checker or disable any of Rust’s other safety checks: if you use a reference in unsafe code, it will still be checked. The `unsafe` keyword only gives you access to @@ -783,6 +784,7 @@ You’ll use default type parameters in two main ways: 1. To extend a type without breaking existing code 1. To allow customization in specific cases most users won’t need + The standard library’s `Add` trait is an example of the second purpose: usually, you’ll add two like types, but the `Add` trait provides the ability to customize beyond that. Using a default type parameter in the `Add` trait diff --git a/nostarch/chapter20.md b/nostarch/chapter20.md index 26136da9..9d4e22cd 100644 --- a/nostarch/chapter20.md +++ b/nostarch/chapter20.md @@ -25,6 +25,7 @@ Here is our plan for building the web server: 1. Parse a small number of HTTP requests. 1. Create a proper HTTP response. 1. Improve the throughput of our server with a thread pool. + Before we get started, we should mention one detail: the method we’ll use won’t be the best way to build a web server with Rust. Community members have published a number of production-ready crates available at *https://crates.io* @@ -1157,6 +1158,7 @@ set up in this way: closure. 1. In `ThreadPool::new`, use the `for` loop counter to generate an `id`, create a new `Worker` with that `id`, and store the `Worker` in the vector. + If you’re up for a challenge, try implementing these changes on your own before looking at the code in Listing 20-15. @@ -1250,6 +1252,7 @@ down the channel. sender. 1. In its thread, the `Worker` will loop over its receiver and execute the closures of any jobs it receives. + Let’s start by creating a channel in `ThreadPool::new` and holding the sender in the `ThreadPool` instance, as shown in Listing 20-16. The `Job` struct doesn’t hold anything for now but will be the type of item we’re sending down diff --git a/tools/docx-to-md.xsl b/tools/docx-to-md.xsl index 01a41826..7efe3c0b 100644 --- a/tools/docx-to-md.xsl +++ b/tools/docx-to-md.xsl @@ -80,10 +80,13 @@ - + 1. + + +