diff --git a/src/lib.rs b/src/lib.rs index 9e87599..7f067b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,9 +74,10 @@ pub fn set_config_name(name: impl Into) { pub fn get_config_name() -> String { if let Some(lock) = CONFIG_NAME.get() && let Ok(guard) = lock.read() - && let Some(name) = guard.as_ref() { - return name.clone(); - } + && let Some(name) = guard.as_ref() + { + return name.clone(); + } DEFAULT_CONFIG_NAME.to_string() } @@ -99,9 +100,10 @@ pub fn clear_custom_dir() { /// Liefert das aktuell gesetzte benutzerdefinierte Konfigurationsverzeichnis, falls vorhanden. pub fn get_custom_dir() -> Option { if let Some(lock) = CUSTOM_CONFIG_DIR.get() - && let Ok(guard) = lock.read() { - return guard.clone(); - } + && let Ok(guard) = lock.read() + { + return guard.clone(); + } None } @@ -124,9 +126,10 @@ pub fn clear_custom_path() { /// Liefert den aktuell gesetzten expliziten Pfad zur Konfigurationsdatei, falls vorhanden. pub fn get_custom_path() -> Option { if let Some(lock) = CUSTOM_CONFIG_PATH.get() - && let Ok(guard) = lock.read() { - return guard.clone(); - } + && let Ok(guard) = lock.read() + { + return guard.clone(); + } None } @@ -261,15 +264,17 @@ where if let Ok(guard) = map_lock.read() && let Some(entry) = guard.get(&TypeId::of::()) - && let Some(val) = entry.downcast_ref::() { - return val; - } + && let Some(val) = entry.downcast_ref::() + { + return val; + } let mut guard = map_lock.write().unwrap(); if let Some(entry) = guard.get(&TypeId::of::()) - && let Some(val) = entry.downcast_ref::() { - return val; - } + && let Some(val) = entry.downcast_ref::() + { + return val; + } let loaded: T = load_config::(); let boxed: &'static T = Box::leak(Box::new(loaded)); diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index e396141..3a705b5 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -16,13 +16,11 @@ fn lock_test() -> std::sync::MutexGuard<'static, ()> { TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner()) } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] -#[derive(Default)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)] struct DummyAppConfig { general: DummyGeneral, } - #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] struct DummyGeneral { log_level: String,