chiark / gitweb /
wip resolve
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 24 Jul 2021 00:14:56 +0000 (01:14 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 24 Jul 2021 00:14:56 +0000 (01:14 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/config.rs

index 34ce97de68008d2ef5719f32e200dd17e34c62cd..fc67125f1212dffdc343b1b747d68e235f141874 100644 (file)
@@ -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<String>) -> $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])