From c497557286e5005de07d918626abcea85fd6be3b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Aug 2021 19:07:48 +0100 Subject: [PATCH] config: Do not use Default for constructing Aggregate We are going to want to add a non-Default field, in a bit. Signed-off-by: Ian Jackson --- src/config.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4e9c710..f08fe71 100644 --- a/src/config.rs +++ b/src/config.rs @@ -161,7 +161,7 @@ pub struct Config { static OUTSIDE_SECTION: &str = "["; static SPECIAL_SERVER_SECTION: &str = "SERVER"; -#[derive(Default,Debug)] +#[derive(Debug)] struct Aggregate { keys_allowed: HashMap<&'static str, SectionKindList>, sections: HashMap, @@ -221,6 +221,13 @@ impl Display for SectionName { } impl Aggregate { + fn new( + keys_allowed: HashMap<&'static str, SectionKindList> + ) -> Self { Aggregate { + keys_allowed, + sections: default(), + } } + #[throws(AE)] // AE does not include path fn read_file(&mut self, path: &Path, anyway: OkAnyway) -> Option { @@ -804,9 +811,8 @@ impl InstanceConfig { #[throws(AE)] pub fn read(opts: &Opts, end: LinkEnd) -> Vec { let agg = (||{ - let mut agg = Aggregate::default(); - agg.keys_allowed.extend( - InstanceConfig::FIELDS.iter().cloned() + let mut agg = Aggregate::new( + InstanceConfig::FIELDS.iter().cloned().collect(), ); agg.read_string(DEFAULT_CONFIG.into(), -- 2.30.2