More lenient type checking for setting parsing

macos-click-through
Jon Valdés 5 years ago
parent 6d2d398c23
commit 1eadd7fad6

@ -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);
}

Loading…
Cancel
Save