aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergio Benitez <sb@sergio.bz>2017-06-19 17:49:55 -0700
committerSergio Benitez <sb@sergio.bz>2017-06-19 17:49:55 -0700
commit6163e708849e5afe171e157bdbc21420ea2a86f1 (patch)
treea04124f3eb6a5aa2a28d6c61b3a26d54d4bbb8df /src
parent46be6329c1c3ee715479396f02e226184c1ba892 (diff)
downloadmilf-rs-6163e708849e5afe171e157bdbc21420ea2a86f1.tar.gz
milf-rs-6163e708849e5afe171e157bdbc21420ea2a86f1.zip
Use 'into()' to convert numerical values safely
Diffstat (limited to 'src')
-rw-r--r--src/value.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/value.rs b/src/value.rs
index 48553fd..5efdb92 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -254,26 +254,24 @@ impl<S: Into<String> + Hash + Eq, V: Into<Value>> From<HashMap<S, V>> for Value
}
macro_rules! impl_into_value {
- ($variant:ident : $T:ty) => (impl_into_value!($variant: $T,););
- ($variant:ident : $T:ty, $($extra:tt)*) => (
+ ($variant:ident : $T:ty) => {
impl From<$T> for Value {
#[inline]
fn from(val: $T) -> Value {
- Value::$variant(val $($extra)*)
+ Value::$variant(val.into())
}
}
- )
+ }
}
impl_into_value!(String: String);
impl_into_value!(Integer: i64);
-impl_into_value!(Integer: isize, as i64);
-impl_into_value!(Integer: i32, as i64);
-impl_into_value!(Integer: i8, as i64);
-impl_into_value!(Integer: u8, as i64);
-impl_into_value!(Integer: u32, as i64);
+impl_into_value!(Integer: i32);
+impl_into_value!(Integer: i8);
+impl_into_value!(Integer: u8);
+impl_into_value!(Integer: u32);
impl_into_value!(Float: f64);
-impl_into_value!(Float: f32, as f64);
+impl_into_value!(Float: f32);
impl_into_value!(Boolean: bool);
impl_into_value!(Datetime: Datetime);