Feat: question mark unwrap.
This commit is contained in:
+1
-9
@@ -12,15 +12,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>>{
|
|||||||
|
|
||||||
// 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