Add an implementation for the case insensitive search

This commit is contained in:
Manuel Thalmann 2025-03-21 07:49:58 +01:00
parent ba37e08a5d
commit 8bbd8391a0
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c

View file

@ -41,9 +41,19 @@ pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
}
pub fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> {
vec![]
let query = query.to_lowercase();
let mut results = Vec::new();
for line in contents.lines() {
if line.to_lowercase().contains(&query) {
results.push(line);
}
}
results
}
#[cfg(test)]
mod tests {
use super::*;