pub fn search<'a>(
query: &str,
contents: &'a str,
) -> impl Iterator<Item = &'a str>Expand description
Searches for lines containing the query string in the provided text.
This function performs a case-sensitive search.
§Arguments
query: The substring to look for.contents: The text to search within.
§Returns
An iterator over lines that contain the query.
§Examples
use minigrep_cli_tool::search;
let query = "safe";
let contents = "Rust is safe.\nFast.\nProductive.";
let results: Vec<&str> = search(query, contents).collect();
assert_eq!(results, vec!["Rust is safe."]);