From 1eadd7fad64339057cebf48d1a7a8fa7656b0b4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vald=C3=A9s?= Date: Thu, 27 Feb 2020 06:23:08 +0100 Subject: [PATCH] More lenient type checking for setting parsing --- src/settings.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/settings.rs b/src/settings.rs index 467ad57..202e5e5 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -28,10 +28,13 @@ impl FromValue for f32 { fn from_value(&mut self, value: Value) { if value.is_f64() { *self = value.as_f64().unwrap() as f32; + }else if value.is_i64() { + *self = value.as_i64().unwrap() as f32; + }else if value.is_u64() { + *self = value.as_u64().unwrap() as f32; }else{ error!("Setting expected an f32, but received {:?}", value); } - } } @@ -81,6 +84,8 @@ impl FromValue for bool { fn from_value(&mut self, value: Value) { if value.is_bool() { *self = value.as_bool().unwrap(); + }else if value.is_u64() { + *self = value.as_u64().unwrap() != 0; }else{ error!("Setting expected a string, but received {:?}", value); }