diff --git a/backend/src/app_util.rs b/backend/src/app_util.rs index eb47124..0c9ac36 100644 --- a/backend/src/app_util.rs +++ b/backend/src/app_util.rs @@ -62,7 +62,7 @@ pub fn get_app_root_dir() -> PathBuf { env::current_exe() .unwrap_or_quit(err_msg) .parent() - .unwrap_or_quit(format!("{err_msg}. Invalid executable path").as_str()) + .unwrap_or_quit(format!("{err_msg}. Invalid executable path")) .to_path_buf() } } diff --git a/backend/src/net_util.rs b/backend/src/net_util.rs index f7314b4..01a6d1c 100644 --- a/backend/src/net_util.rs +++ b/backend/src/net_util.rs @@ -78,7 +78,7 @@ pub async fn init_server() { // TCP listener let listener = TcpListener::bind(SocketAddr::from(([0, 0, 0, 0], *port))) .await - .unwrap_or_quit(format!("Failed to start the server on port \"{port}\"").as_str()); + .unwrap_or_quit(format!("Failed to start the server on port \"{port}\"")); log_success!( "UFC Ripper (v{}) GUI is live at http://localhost:{port} {}\n", diff --git a/backend/src/rt_util.rs b/backend/src/rt_util.rs index 8419389..d7f292a 100644 --- a/backend/src/rt_util.rs +++ b/backend/src/rt_util.rs @@ -30,7 +30,7 @@ impl Drop for ExitHandler { /// Implements custom unwrap functionality which quits the application when fails pub trait QuitUnwrap { /// Unwraps the value or quits the application with a custom message - fn unwrap_or_quit(self, msg: &str) -> T; + fn unwrap_or_quit(self, msg: impl AsRef) -> T; } // Implements `QuitUnwrap` for `Result` @@ -38,20 +38,20 @@ impl QuitUnwrap for Result where E: Display, { - fn unwrap_or_quit(self, msg: &str) -> T { + fn unwrap_or_quit(self, msg: impl AsRef) -> T { match self { Ok(val) => val, - Err(err) => quit(Some(format!("Error: {err}\n{msg}").as_str())), + Err(err) => quit(Some(&format!("Error: {err}\n{}", msg.as_ref()))), } } } // Implements `QuitUnwrap` for `Option` impl QuitUnwrap for Option { - fn unwrap_or_quit(self, msg: &str) -> T { + fn unwrap_or_quit(self, msg: impl AsRef) -> T { match self { Some(val) => val, - None => quit(Some(msg)), + None => quit(Some(msg.as_ref())), } } }