Function search_case_insensitive

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

Searches for the query string in the contents, case-insensitive.

§Arguments

  • query - The string to search for.
  • contents - The contents of the file to search in.

§Returns

  • Vec<&str> - A vector of lines that contain the query string, ignoring case.

§Examples

use quewuigrep::search_case_insensitive;
 
let query = "rUsT";
let contents = "\
Rust:
safe, fast, productive.
Pick three.
Trust me.";
 
let result = search_case_insensitive(query, contents);
assert_eq!(result, vec!["Rust:", "Trust me."]);