made code more concise

This commit is contained in:
jannikac 2022-12-06 23:21:29 +01:00
parent 283cb589bd
commit 87c457a83e

View file

@ -72,7 +72,7 @@ pub fn load_config(opts: &opts::Opts) -> anyhow::Result<Config> {
Some(config_path) => load_config_from(config_path), Some(config_path) => load_config_from(config_path),
None => { None => {
let confpath = ProjectDirs::from("me", "kaangenc", "gandi-dynamic-dns") let confpath = ProjectDirs::from("me", "kaangenc", "gandi-dynamic-dns")
.and_then(|dir| Some(PathBuf::from(dir.config_dir()).join("config.toml"))) .map(|dir| PathBuf::from(dir.config_dir()).join("config.toml"))
.ok_or(anyhow::anyhow!("Can't find config directory")); .ok_or(anyhow::anyhow!("Can't find config directory"));
confpath confpath
.and_then(|path| { .and_then(|path| {
@ -92,11 +92,9 @@ pub fn load_config(opts: &opts::Opts) -> anyhow::Result<Config> {
.entry .entry
.into_iter() .into_iter()
.map(|mut entry| { .map(|mut entry| {
entry.types = entry entry
.types .types
.into_iter() .retain(|v| (v == "A" && !opts.skip_ipv4) || (v == "AAAA" && !opts.skip_ipv6));
.filter(|v| (v == "A" && !opts.skip_ipv4) || (v == "AAAA" && !opts.skip_ipv6))
.collect();
entry entry
}) })
.collect(); .collect();