use crate::argument::ArgumentValue;
use crate::argument::internal::Sealed;
pub(in crate::argument) trait NumericValue: Sealed + Copy + PartialOrd {
#[must_use]
fn zero() -> Self;
fn to_argument_value(self) -> ArgumentValue;
#[must_use]
fn is_nan(self) -> bool;
}
macro_rules! impl_numeric_value_for_integer {
($($numeric_type:ty),+ $(,)?) => {
$(
impl NumericValue for $numeric_type {
#[inline]
fn zero() -> Self {
0
}
#[inline]
fn to_argument_value(self) -> ArgumentValue {
ArgumentValue::from(self)
}
#[inline]
fn is_nan(self) -> bool {
false
}
}
)+
};
}
impl_numeric_value_for_integer!(i8, i16, i32, i64, i128, isize);
impl_numeric_value_for_integer!(u8, u16, u32, u64, u128, usize);
impl NumericValue for f32 {
#[inline]
fn zero() -> Self {
0.0
}
#[inline]
fn to_argument_value(self) -> ArgumentValue {
ArgumentValue::from(self)
}
#[inline]
fn is_nan(self) -> bool {
self.is_nan()
}
}
impl NumericValue for f64 {
#[inline]
fn zero() -> Self {
0.0
}
#[inline]
fn to_argument_value(self) -> ArgumentValue {
ArgumentValue::from(self)
}
#[inline]
fn is_nan(self) -> bool {
self.is_nan()
}
}