use std::{ fs::File, io::{BufRead, BufReader}, }; use anyhow::Context; pub fn read_lines( file_path: &str, ) -> anyhow::Result>, anyhow::Error> { if file_path.is_empty() { return Err(anyhow::anyhow!("File path cannot be empty")); } let file = File::open(file_path).with_context(|| format!("failed to open file: {file_path}"))?; let reader = BufReader::new(file); Ok(reader.lines()) } pub fn consume_lines(iter: impl Iterator>) { for line in iter { let line = line.unwrap_or("".into()); println!("{line}"); } }