use crate::{consts::msg, RangedI32};
use std::ops::{Add, AddAssign};
#[allow(clippy::use_self)]
impl<const START: i32, const END: i32, const START_RHS: i32, const END_RHS: i32>
Add<RangedI32<START_RHS, END_RHS>> for RangedI32<START, END>
where
RangedI32<{ START + START_RHS }, { END + END_RHS - 1 }>: ,
{
#[allow(clippy::suspicious_arithmetic_impl)]
type Output = RangedI32<{ START + START_RHS }, { END + END_RHS - 1 }>;
#[allow(clippy::integer_arithmetic)]
fn add(self, rhs: RangedI32<START_RHS, END_RHS>) -> Self::Output {
Self::Output::new(self.value + rhs.value).unwrap_or_else(|| {
unreachable!(msg::ERR_INTERNAL_VALUE_UNEXPECTEDLY_EXCEEDED_RANGE_BOUNDS)
})
}
}
#[allow(unconditional_recursion)]
impl<const START: i32, const END: i32, const START_RHS: i32, const END_RHS: i32>
AddAssign<RangedI32<START_RHS, END_RHS>> for RangedI32<START, END>
{
#[inline]
fn add_assign(&mut self, rhs: RangedI32<START_RHS, END_RHS>) { *self += rhs }
}