summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2023-03-02 23:42:41 +0400
committerJoursoir <chat@joursoir.net>2023-03-02 23:42:41 +0400
commit74361b83133822fef6d8a4baf1b0d70e22f9e04e (patch)
treef5ee07f2af2abdb7a3fa83a69729c259303d25ed /src
parent1890006df3d79a767bfdc1b981c658f7033d8fd2 (diff)
downloadtrgrep-74361b83133822fef6d8a4baf1b0d70e22f9e04e.tar.gz
trgrep-74361b83133822fef6d8a4baf1b0d70e22f9e04e.tar.bz2
trgrep-74361b83133822fef6d8a4baf1b0d70e22f9e04e.zip
iterate over lines instead of reading all bytes into a String
Diffstat (limited to 'src')
-rw-r--r--src/main.rs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 767914d..af3b56a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -43,10 +43,7 @@ fn run(config: Config) -> Result<(), Box<dyn Error>> {
&mut file_read
};
- let mut contents = String::new();
- reader.read_to_string(&mut contents)?;
-
- for line in trgrep::search(&config.pattern, &contents) {
+ for line in reader.lines().map(|l| l.unwrap().contains(&config.pattern)) {
println!("{line}");
}
}