From 74361b83133822fef6d8a4baf1b0d70e22f9e04e Mon Sep 17 00:00:00 2001 From: Joursoir Date: Thu, 2 Mar 2023 23:42:41 +0400 Subject: iterate over lines instead of reading all bytes into a String --- src/main.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') 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> { &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}"); } } -- cgit v1.2.3-18-g5258