#[cfg(feature = "ixy")]
pub use ixy::int::SignedInt;
#[cfg(not(feature = "ixy"))]
pub use self::local::SignedInt;
#[cfg(not(feature = "ixy"))]
mod local {
use crate::internal::Sealed;
use core::ops::{
Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign,
};
#[allow(private_bounds)]
pub trait SignedInt:
Sealed
+ Copy
+ Eq
+ Ord
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAssign
+ Mul<Output = Self>
+ MulAssign
+ Div<Output = Self>
+ DivAssign
+ Rem<Output = Self>
+ RemAssign
+ Neg<Output = Self>
+ core::fmt::Debug
+ core::fmt::Display
{
const ZERO: Self;
const ONE: Self;
const TWO: Self;
const NEG_ONE: Self;
const MIN: Self;
const MAX: Self;
#[must_use]
fn abs(self) -> Self;
#[must_use]
fn signum(self) -> Self;
#[must_use]
fn clamp(self, lo: Self, hi: Self) -> Self;
}
macro_rules! impl_signed {
($($t:ty),*) => { $(
impl Sealed for $t {}
impl SignedInt for $t {
const ZERO: Self = 0;
const ONE: Self = 1;
const TWO: Self = 2;
const NEG_ONE: Self = -1;
const MIN: Self = <$t>::MIN;
const MAX: Self = <$t>::MAX;
fn abs(self) -> Self { <$t>::abs(self) }
fn signum(self) -> Self { <$t>::signum(self) }
fn clamp(self, lo: Self, hi: Self) -> Self { Ord::clamp(self, lo, hi) }
}
)* };
}
impl_signed!(i8, i16, i32, i64, i128, isize);
}