From 72d69021367c70b56292d9b1417e0591909ba8af Mon Sep 17 00:00:00 2001 From: Valerie Wolfe Date: Mon, 12 Aug 2024 15:07:02 -0400 Subject: [PATCH] error methods now have the correct return type --- mkwin/src/error.rs | 4 ++-- mkwin/src/main.rs | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mkwin/src/error.rs b/mkwin/src/error.rs index 846abef..e2e3d95 100644 --- a/mkwin/src/error.rs +++ b/mkwin/src/error.rs @@ -3,13 +3,13 @@ use std::process::exit; /// no argument for target; code 1 -pub fn missing_target() { +pub fn missing_target() -> ! { eprintln!("mkwin: missing target"); exit(1); } /// failed to canonicalize target path; code 2 -pub fn canonicalize_fail(target: String) { +pub fn canonicalize_fail(target: String) -> ! { eprintln!("mkwin: failed to canonicalze '{target}'--does the file exist?"); exit(2); } diff --git a/mkwin/src/main.rs b/mkwin/src/main.rs index b3cbb95..d8a5dad 100644 --- a/mkwin/src/main.rs +++ b/mkwin/src/main.rs @@ -73,15 +73,9 @@ pub fn main() { if let Ok(path) = path.canonicalize() { let path: String = path.to_string_lossy().into(); target = format!("'{path}'"); - } else { - error::canonicalize_fail(arg); - return; - } + } else { error::canonicalize_fail(arg); } } - } else { - error::missing_target(); - return; - } + } else { error::missing_target(); } // construct output println!("#!/usr/bin/bash\n# generated with: mkwin{arg_string}\n");