Feat: extract find_matches into own function.
This commit is contained in:
+11
-5
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user