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()))?;
|
||||
|
||||
|
||||
for line in content.lines() {
|
||||
if line.contains(&args.pattern) {
|
||||
println!("{}", line)
|
||||
}
|
||||
}
|
||||
find_matches(content.as_str(), args.pattern.as_str());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn find_matches(content: &str, pattern: &str) {
|
||||
for line in content.lines() {
|
||||
if line.contains(pattern) {
|
||||
println!("{}", line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn answer() -> i32 {
|
||||
return 42;
|
||||
|
||||
Reference in New Issue
Block a user