Function minigrep_test_package_001::search_case_insensitive[][src]

pub fn search_case_insensitive<'a>(
    query: &str,
    contents: &'a str
) -> Vec<&'a str>
Expand description

search through each line in given contents and return any lines containing a case-insensitive match to the query.

(i.e., query "RuSt" would match line "rust")

Arguments

  • query: a query string to search for
  • contents: the contents within which we should search for the given query

Examples

use minigrep::search_case_insensitive;

let query = "DUCT"; // 'DUCT' will match 'productive' b/c case-insensitive
let contents = "\
Rust:
safe, fast, productive.
Pick three.";

assert_eq!(vec!["safe, fast, productive."], search_case_insensitive(query, contents));