the first step is again to write a failing test. We’ll add a new test for the
new `search_case_insensitive` function and rename our old test from
`one_result` to `case_sensitive` to clarify the differences between the two
-tests, as shown in Listing 12-20:
+tests, as shown in Listing 12-20.
<span class="filename">Filename: src/lib.rs</span>
Note that we’ve edited the old test’s `contents` too. We’ve added a new line
with the text `"Duct tape."` using a capital D that shouldn’t match the query
-“duct” when we’re searching in a case-sensitive manner. Changing the old test
+`"duct"` when we’re searching in a case-sensitive manner. Changing the old test
in this way helps ensure that we don’t accidentally break the case-sensitive
search functionality that we’ve already implemented. This test should pass now
and should continue to pass as we work on the case-insensitive search.
<span class="filename">Filename: src/lib.rs</span>
```rust
-fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
+pub fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
let query = query.to_lowercase();
let mut results = Vec::new();
Great! They passed. Now, let’s call the new `search_case_insensitive` function
from the `run` function. First, we’ll add a configuration option to the
`Config` struct to switch between case-sensitive and case-insensitive search.
-Adding this field will cause compiler errors since we aren’t initializing this
-field anywhere yet:
+Adding this field will cause compiler errors because we aren’t initializing
+this field anywhere yet:
<span class="filename">Filename: src/lib.rs</span>
need the `run` function to check the `case_sensitive` field’s value and use
that to decide whether to call the `search` function or the
`search_case_insensitive` function, as shown in Listing 12-22. Note this still
-won’t compile yet:
+won’t compile yet.
<span class="filename">Filename: src/lib.rs</span>
# vec![]
# }
#
-# fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
+# pub fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
# vec![]
# }
#
Finally, we need to check for the environment variable. The functions for
working with environment variables are in the `env` module in the standard
library, so we want to bring that module into scope with a `use std::env;` line
-at the top of *src/lib.rs*. Then we’ll use the `var` method from the `env`
+at the top of *src/lib.rs*. Then we’ll use the `var` function from the `env`
module to check for an environment variable named `CASE_INSENSITIVE`, as shown
-in Listing 12-23:
+in Listing 12-23.
<span class="filename">Filename: src/lib.rs</span>
Here, we create a new variable `case_sensitive`. To set its value, we call the
`env::var` function and pass it the name of the `CASE_INSENSITIVE` environment
-variable. The `env::var` method returns a `Result` that will be the successful
+variable. The `env::var` function returns a `Result` that will be the successful
`Ok` variant that contains the value of the environment variable if the
environment variable is set. It will return the `Err` variant if the
environment variable is not set.