From 1cc76980b308d32803e5d392f4472cc09f70d75a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 24 Jul 2021 01:14:56 +0100 Subject: [PATCH] wip resolve Signed-off-by: Ian Jackson --- src/config.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/config.rs b/src/config.rs index 34ce97d..fc67125 100644 --- a/src/config.rs +++ b/src/config.rs @@ -275,6 +275,16 @@ impl Parseable for Duration { throw!(anyhow!("xxx parse with humantime")) } } +macro_rules! parseable_from_str { ($t:ty) => { + impl Parseable for $t { + #[throws(AE)] + fn parse(s: &Option) -> $t { + let s = s.as_ref().ok_or_else(|| anyhow!("value needed"))?; + s.parse()? + } + } +} } +parseable_from_str!{u32} impl<'c> ResolveContext<'c> { fn first_of_raw(&self, key: &'static str, sections: &[SectionName]) -- 2.30.2