Feat: question mark unwrap.
This commit is contained in:
+2
-10
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user