From 5ae890f94178d824fb73b4bbd2938dff9c22e96e Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 30 Oct 2022 15:42:43 -0500 Subject: [PATCH] replace an expect with unwrap_or_else --- azalea-client/src/account.rs | 7 +++---- azalea/src/lib.rs | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/azalea-client/src/account.rs b/azalea-client/src/account.rs index 2fedc4f5..42bfe6fc 100644 --- a/azalea-client/src/account.rs +++ b/azalea-client/src/account.rs @@ -46,13 +46,12 @@ impl Account { /// a key for the cache, but it's recommended to use the real email to /// avoid confusion. pub async fn microsoft(email: &str) -> Result { - let minecraft_dir = get_mc_dir::minecraft_dir().expect( - format!( + let minecraft_dir = get_mc_dir::minecraft_dir().unwrap_or_else(|| { + panic!( "No {} environment variable found", get_mc_dir::home_env_var() ) - .as_str(), - ); + }); let auth_result = azalea_auth::auth( email, azalea_auth::AuthOpts { diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs index d9465062..636981f3 100644 --- a/azalea/src/lib.rs +++ b/azalea/src/lib.rs @@ -122,7 +122,6 @@ where /// # Examples /// /// ```rust - /// use anyhow::Result; /// use azalea::prelude::*; /// /// async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {