From: Ian Jackson Date: Sat, 24 Jul 2021 00:14:56 +0000 (+0100) Subject: wip resolve X-Git-Tag: hippotat/1.0.0~503 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=1cc76980b308d32803e5d392f4472cc09f70d75a;p=hippotat.git wip resolve Signed-off-by: Ian Jackson --- 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])