1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::{Number, Value};
macro_rules! impl_from_small_ints_for_value { ($($ty: ty, $code: tt,)+) => {
$(
impl From<$ty> for Value {
fn from(n: $ty) -> Self {
Value::Number(Number {
inner: super::super::Inner::$code(n.into()),
})
}
}
)+
}}
impl_from_small_ints_for_value! {
i8, I32, i16, I32,
u8, U32, u16, U32,
}
macro_rules! impl_from_primitives_for_value { ($($ty: ty, $code: tt,)+) => {
$(
impl From<$ty> for Value {
fn from(n: $ty) -> Self {
Value::Number(Number {
inner: super::super::Inner::$code(n),
})
}
}
)+
}}
impl_from_primitives_for_value! {
i32, I32, i64, I64, i128, I128, isize, ISize,
u32, U32, u64, U64, u128, U128, usize, USize,
f32, F32, f64, F64,
}