Feat: question mark unwrap.

This commit is contained in:
Ian Rettig
2025-06-06 17:02:32 -04:00
parent d41577ef7d
commit d7d2c74b23
+2 -10
View File
@@ -7,20 +7,12 @@ struct Cli {
path: std::path::PathBuf, path: std::path::PathBuf,
} }
fn main() -> Result<(), Box<dyn std::error::Error>>{ fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::parse(); let args = Cli::parse();
// let content = std::fs::read_to_string(&args.path).expect("Could not read file."); // let content = std::fs::read_to_string(&args.path).expect("Could not read file.");
let result = std::fs::read_to_string(&args.path); let content = std::fs::read_to_string(&args.path)?;
let content = match result {
Ok(content) => {
content
},
Err(error) => {
return Err(error.into());
}
};
for line in content.lines() { for line in content.lines() {
if line.contains(&args.pattern) { if line.contains(&args.pattern) {