use num_traits::{Num, Bounded};
pub trait Number: Num + Bounded + PartialOrd + Copy {
fn min(self, other: Self) -> Self {
if self < other {
self
} else {
other
}
}
fn max(self, other: Self) -> Self {
if self > other {
self
} else {
other
}
}
fn is_nan(&self) -> bool {
false
}
}
impl Number for f32 {
fn is_nan(&self) -> bool {
f32::is_nan(*self)
}
}
impl Number for f64 {
fn is_nan(&self) -> bool {
f64::is_nan(*self)
}
}
impl Number for u8 {}
impl Number for u16 {}
impl Number for u32 {}
impl Number for u64 {}
impl Number for u128 {}
impl Number for i8 {}
impl Number for i16 {}
impl Number for i32 {}
impl Number for i64 {}
impl Number for i128 {}
impl Number for usize {}
impl Number for isize {}