From b84e470a4250119ffd02c36839f2cf24137c5835 Mon Sep 17 00:00:00 2001 From: notplants Date: Wed, 11 May 2022 11:24:33 +0200 Subject: [PATCH] Remove unecessary .to_string --- peach-lib/src/config_manager.rs | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/peach-lib/src/config_manager.rs b/peach-lib/src/config_manager.rs index 5c9a849..840b11b 100644 --- a/peach-lib/src/config_manager.rs +++ b/peach-lib/src/config_manager.rs @@ -41,34 +41,33 @@ lazy_static! { // Default values for PeachCloud configs which are used for any key which is not set // via an environment variable or in a saved configuration file. pub fn get_peach_config_defaults() -> HashMap { - let peach_config_defaults: HashMap = HashMap::from([ - ("STANDALONE_MODE".to_string(), "true".to_string()), - ("DISABLE_AUTH".to_string(), "false".to_string()), - ("ADDR".to_string(), "127.0.0.1".to_string()), - ("PORT".to_string(), "8000".to_string()), - ("EXTERNAL_DOMAIN".to_string(), "".to_string()), - ("DYN_DOMAIN".to_string(), "".to_string()), + let peach_config_defaults: HashMap<&str, &str> = HashMap::from([ + ("STANDALONE_MODE", "true"), + ("DISABLE_AUTH", "false"), + ("ADDR", "127.0.0.1"), + ("PORT", "8000"), + ("EXTERNAL_DOMAIN", ""), + ("DYN_DOMAIN", ""), ( - "DYN_DNS_SERVER_ADDRESS".to_string(), - "http://dynserver.dyn.peachcloud.org".to_string(), - ), - ("DYN_USE_CUSTOM_SERVER".to_string(), "true".to_string()), - ("DYN_TSIG_KEY_PATH".to_string(), "".to_string()), - ( - "DYN_NAMESERVER".to_string(), - "ns.peachcloud.org".to_string(), - ), - ("DYN_ENABLED".to_string(), "false".to_string()), - ("SSB_ADMIN_IDS".to_string(), "".to_string()), - ("ADMIN_PASSWORD_HASH".to_string(), "146".to_string()), - ("TEMPORARY_PASSWORD_HASH".to_string(), "".to_string()), - ("GO_SBOT_DATADIR".to_string(), "".to_string()), - ( - "PEACH_CONFIGDIR".to_string(), - "/var/lib/peachcloud".to_string(), + "DYN_DNS_SERVER_ADDRESS", + "http://dynserver.dyn.peachcloud.org", ), + ("DYN_USE_CUSTOM_SERVER", "true"), + ("DYN_TSIG_KEY_PATH", ""), + ("DYN_NAMESERVER", "ns.peachcloud.org"), + ("DYN_ENABLED", "false"), + ("SSB_ADMIN_IDS", ""), + ("ADMIN_PASSWORD_HASH", "146"), + ("TEMPORARY_PASSWORD_HASH", ""), + ("GO_SBOT_DATADIR", ""), + ("PEACH_CONFIGDIR", "/var/lib/peachcloud"), ]); - peach_config_defaults + // convert HashMap<&str, &str> to HashMap and return + let pc_defaults: HashMap = peach_config_defaults + .iter() + .map(|(key, val)| (key.to_string(), val.to_string())) + .collect(); + pc_defaults } // primary interface for getting config values