summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorPrince <princedaryl3@tutanota.com>2021-05-16 11:20:16 +0300
committerPrince <princedaryl3@tutanota.com>2021-05-16 11:20:16 +0300
commit111bbf64eaaec0d6803ce2a03d428f865f1dea83 (patch)
treeb4b349583c506be72ba9823c4f02b30f9c87338d /src/main.rs
parent7e61bcce2eddcacc6a719eb7aa576d5f7c785436 (diff)
make error handling clearer with "if let"
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index cdb6214..1716ece 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -71,12 +71,9 @@ fn run_joshuto(args: Args) -> Result<(), JoshutoError> {
return Ok(());
}
if let Some(p) = args.path.as_ref() {
- match std::env::set_current_dir(p.as_path()) {
- Ok(_) => {}
- Err(e) => {
- eprintln!("{}", e);
- process::exit(1);
- }
+ if let Err(e) = std::env::set_current_dir(p.as_path()) {
+ eprintln!("{}", e);
+ process::exit(1);
}
}
@@ -108,11 +105,8 @@ fn run_joshuto(args: Args) -> Result<(), JoshutoError> {
fn main() {
let args = Args::from_args();
- match run_joshuto(args) {
- Ok(_) => {}
- Err(e) => {
- eprintln!("{}", e.to_string());
- process::exit(1);
- }
+ if let Err(e) = run_joshuto(args) {
+ eprintln!("{}", e.to_string());
+ process::exit(1);
}
}