Feat: extract find_matches into own function.

This commit is contained in:
Ian Rettig
2025-06-09 11:47:23 -04:00
parent ec63f6f022
commit 7cca8410e1
+11 -5
View File
@@ -20,15 +20,21 @@ fn main() -> Result<()> {
.with_context(|| format!("could not read file `{}`.", args.path.display()))?; .with_context(|| format!("could not read file `{}`.", args.path.display()))?;
for line in content.lines() { find_matches(content.as_str(), args.pattern.as_str());
if line.contains(&args.pattern) {
println!("{}", line)
}
}
Ok(()) Ok(())
} }
fn find_matches(content: &str, pattern: &str) {
for line in content.lines() {
if line.contains(pattern) {
println!("{}", line)
}
}
}
#[allow(dead_code)] #[allow(dead_code)]
fn answer() -> i32 { fn answer() -> i32 {
return 42; return 42;