Skip to content

Commit

Permalink
Fix for shorter if let lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Oct 21, 2023
1 parent e30f0a9 commit a285709
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,13 @@ fn build_app() -> App<'static, 'static> {

fn get_config_file_path() -> String {
#[cfg(windows)]
return format!("{}/sisterm/config.toml",
if let Ok(ref user) = env::var("LOCALAPPDATA") { user } else { "%LOCALAPPDATA%" } );

const VAR_AND_FALLBACK: (&str, &str) = ("LOCALAPPDATA", "%LOCALAPPDATA%");
#[cfg(not(windows))]
return format!("{}/.config/sisterm/config.toml",
if let Ok(ref home) = env::var("HOME") { home } else { "$HOME" } );
const VAR_AND_FALLBACK: (&str, &str) = ("HOME", "$HOME");
let var = env::var(VAR_AND_FALLBACK.0);

format!("{}/sisterm/config.toml",
if let Ok(ref home) = var { home } else { VAR_AND_FALLBACK.1 })
}

fn config_file_help_message() -> &'static str {
Expand Down

0 comments on commit a285709

Please sign in to comment.