summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-10-27 14:34:19 +0200
committerGitHub <noreply@github.com>2023-10-27 14:34:19 +0200
commit46240e4a9c72c4242f40d3da8925a4820af49eab (patch)
treea9c34935e3bad252cdc8f90a9ce0a89360fdca9a
parent76e222411528a370e2b8433cfdc46d9f74f52c1e (diff)
refactor(config): simplify config path finding (#145)
I just found that this could be written with less code, so that's what I did here. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--systeroid-core/src/config.rs9
1 files changed, 1 insertions, 8 deletions
diff --git a/systeroid-core/src/config.rs b/systeroid-core/src/config.rs
index 5418548..3992da7 100644
--- a/systeroid-core/src/config.rs
+++ b/systeroid-core/src/config.rs
@@ -108,14 +108,7 @@ impl Config {
if path.is_some() {
config_paths.insert(0, path);
}
- let mut config_path = None;
- for path in config_paths.into_iter().flatten() {
- if path.exists() {
- config_path = Some(path);
- break;
- }
- }
- if let Some(path) = config_path {
+ if let Some(path) = config_paths.into_iter().flatten().find(|p| p.exists()) {
log::trace!(target: "config", "Parsing configuration from {:?}", path);
let ini = Ini::load_from_file(path)?;
if let Some(general_section) = ini.section(Some("general")) {