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>
This commit is contained in:
Matthias Beyer 2023-10-27 14:34:19 +02:00 committed by GitHub
parent 76e2224115
commit 46240e4a9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")) {