use crate::{Clamp, One, Zero};
macro_rules! impl_int {
($($type:ty),*) => {$(
impl Zero for $type {
fn zero() -> Self { 0 }
fn is_zero(&self) -> bool { *self == 0 }
}
impl One for $type {
fn one() -> Self { 1 }
fn is_one(&self) -> bool { *self == 1 }
}
impl Clamp for $type {
fn min(self, other: Self) -> Self { Ord::min(self, other) }
fn max(self, other: Self) -> Self { Ord::max(self, other) }
fn clamp(self, lower: Self, upper: Self) -> Self { Ord::clamp(self, lower, upper) }
}
)*};
}
impl_int!(
i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize
);
#[cfg(feature = "std")]
mod from_str_radix {
use crate::FromStrRadix;
macro_rules! impl_from_str_radix {
($($type:ty),*) => {$(
impl FromStrRadix for $type {
type Error = core::num::ParseIntError;
fn from_str_radix(source: &str, radix: u32) -> Result<Self, Self::Error> {
<$type>::from_str_radix(source, radix)
}
}
)*};
}
impl_from_str_radix!(
i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize
);
}