// License: see LICENSE file at root directory of `master` branch

//! # Implementations for `Value`

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,
}
