summaryrefslogtreecommitdiffstats
path: root/src/config.rs
diff options
context:
space:
mode:
authorQingping Hou <dave2008713@gmail.com>2019-12-06 08:57:42 -0800
committerMatan Kushner <hello@matchai.me>2019-12-06 11:57:42 -0500
commitc5a206e3cf5ea01eed98c3c7f79089a450d60b33 (patch)
tree38abdd7f7522210edac3471a2b9426e0493b9eaf /src/config.rs
parent5b440c0bb01b35eff1ebd92af1a2c013668fed04 (diff)
feat: Add git_commit module (#673)
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 027ca75ac..c2c8c0a45 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -98,6 +98,22 @@ impl<'a> ModuleConfig<'a> for f64 {
}
}
+impl<'a> ModuleConfig<'a> for usize {
+ fn from_config(config: &Value) -> Option<Self> {
+ match config {
+ Value::Integer(value) => {
+ if *value > 0 {
+ Some(*value as usize)
+ } else {
+ None
+ }
+ }
+ Value::String(value) => value.parse::<usize>().ok(),
+ _ => None,
+ }
+ }
+}
+
impl<'a, T> ModuleConfig<'a> for Vec<T>
where
T: ModuleConfig<'a>,