mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-02-02 23:38:41 +08:00
Merge pull request #428 from fusepilot/patch-1
Missing search.to_lowercase() in grep_case_insensitive
This commit is contained in:
commit
d369804c5a
@ -168,6 +168,8 @@ number when we sent you chapter 12, we will fix it. /Carol -->
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn grep_case_insensitive<'a>(search: &str, contents: &'a str) -> Vec<&'a str> {
|
fn grep_case_insensitive<'a>(search: &str, contents: &'a str) -> Vec<&'a str> {
|
||||||
|
let search = search.to_lowercase();
|
||||||
|
|
||||||
contents.lines()
|
contents.lines()
|
||||||
.filter(|line| {
|
.filter(|line| {
|
||||||
line.to_lowercase().contains(&search)
|
line.to_lowercase().contains(&search)
|
||||||
|
Loading…
Reference in New Issue
Block a user