macro_rules! gen_clamp_impl {
($i:ty) => {
paste!{
impl<const MIN: $i, const MAX: $i> std::ops::Add for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn add(self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>) -> Self::Output {
self + rhs.inner()
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Add<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn add(self, rhs: $i) -> Self::Output {
Self::new(self.inner().saturating_add(rhs))
}
}
impl<const MIN: $i, const MAX: $i> std::ops::AddAssign for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn add_assign(&mut self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>)
{
*self = *self + rhs;
}
}
impl<const MIN: $i, const MAX: $i> std::ops::AddAssign<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn add_assign(&mut self, rhs: $i)
{
*self = Self::new(self.inner().saturating_add(rhs));
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Sub for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn sub(self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>) -> Self::Output {
self - rhs.inner()
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Sub<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn sub(self, rhs: $i) -> Self::Output {
Self::new(self.inner().saturating_sub(rhs))
}
}
impl<const MIN: $i, const MAX: $i> std::ops::SubAssign for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn sub_assign(&mut self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>)
{
*self -= rhs.inner();
}
}
impl<const MIN: $i, const MAX: $i> std::ops::SubAssign<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn sub_assign(&mut self, rhs: $i)
{
*self = Self::new(self.inner().saturating_sub(rhs));
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Mul for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn mul(self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>) -> Self::Output {
self * rhs.inner()
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Mul<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn mul(self, rhs: $i) -> Self::Output {
Self::new(self.inner().saturating_mul(rhs))
}
}
impl<const MIN: $i, const MAX: $i> std::ops::MulAssign for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn mul_assign(&mut self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>)
{
*self = *self * rhs;
}
}
impl<const MIN: $i, const MAX: $i> std::ops::MulAssign<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn mul_assign(&mut self, rhs: $i)
{
*self = *self * rhs;
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Div for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn div(self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>) -> Self::Output {
self / rhs.inner()
}
}
impl<const MIN: $i, const MAX: $i> std::ops::Div<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
type Output = Self;
fn div(self, rhs: $i) -> Self::Output {
Self::new(self.inner().saturating_div(rhs))
}
}
impl<const MIN: $i, const MAX: $i> std::ops::DivAssign for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn div_assign(&mut self, rhs: [<Ranged $i:upper>]<MIN,MAX, op_mode::Clamp>)
{
*self = *self / rhs;
}
}
impl<const MIN: $i, const MAX: $i> std::ops::DivAssign<$i> for [<Ranged $i:upper>]<MIN, MAX, op_mode::Clamp>
{
fn div_assign(&mut self, rhs: $i)
{
*self = *self / rhs;
}
}
}
};
}