use core::ops::{Add, AddAssign, Sub, SubAssign};
use rinia::numeric::{SaturatingAdd, SaturatingSub};
use crate::FrameIndex;
impl<T> Add for FrameIndex<T>
where
T: Add<Output = T>,
{
type Output = Self;
#[inline]
fn add(self, rhs: Self) -> Self::Output {
Self(self.0 + rhs.0)
}
}
impl<T> AddAssign for FrameIndex<T>
where
T: AddAssign,
{
#[inline]
fn add_assign(&mut self, rhs: Self) {
self.0 += rhs.0;
}
}
impl<T> Sub for FrameIndex<T>
where
T: Sub<Output = T>,
{
type Output = Self;
#[inline]
fn sub(self, rhs: Self) -> Self::Output {
Self(self.0 - rhs.0)
}
}
impl<T> SubAssign for FrameIndex<T>
where
T: SubAssign,
{
#[inline]
fn sub_assign(&mut self, rhs: Self) {
self.0 -= rhs.0;
}
}
impl<T> Add<T> for FrameIndex<T>
where
T: Add<Output = T>,
{
type Output = Self;
#[inline]
fn add(self, rhs: T) -> Self::Output {
Self(self.0 + rhs)
}
}
impl<T> AddAssign<T> for FrameIndex<T>
where
T: AddAssign,
{
#[inline]
fn add_assign(&mut self, rhs: T) {
self.0 += rhs;
}
}
impl<T> Sub<T> for FrameIndex<T>
where
T: Sub<Output = T>,
{
type Output = Self;
#[inline]
fn sub(self, rhs: T) -> Self::Output {
Self(self.0 - rhs)
}
}
impl<T> SubAssign<T> for FrameIndex<T>
where
T: SubAssign,
{
#[inline]
fn sub_assign(&mut self, rhs: T) {
self.0 -= rhs;
}
}
impl<T> FrameIndex<T>
where
T: SaturatingAdd<Output = T>,
{
#[inline]
pub fn saturating_add(self, rhs: Self) -> Self {
let value = self.0.saturating_add(rhs.0);
Self(value)
}
#[inline]
pub fn saturating_add_t(self, rhs: T) -> Self {
let value = self.0.saturating_add(rhs);
Self(value)
}
}
impl<T> SaturatingAdd for FrameIndex<T>
where
T: SaturatingAdd<Output = T>,
{
type Output = Self;
#[inline]
fn saturating_add(self, rhs: Self) -> Self::Output {
FrameIndex::saturating_add(self, rhs)
}
}
impl<T> SaturatingAdd<T> for FrameIndex<T>
where
T: SaturatingAdd<Output = T>,
{
type Output = Self;
#[inline]
fn saturating_add(self, rhs: T) -> Self::Output {
FrameIndex::saturating_add_t(self, rhs)
}
}
impl<T> FrameIndex<T>
where
T: SaturatingSub<Output = T>,
{
#[inline]
pub fn saturating_sub(self, rhs: Self) -> Self {
let value = self.0.saturating_sub(rhs.0);
Self(value)
}
#[inline]
pub fn saturating_sub_t(self, rhs: T) -> Self {
let value = self.0.saturating_sub(rhs);
Self(value)
}
}
impl<T> SaturatingSub for FrameIndex<T>
where
T: SaturatingSub<Output = T>,
{
type Output = Self;
#[inline]
fn saturating_sub(self, rhs: Self) -> Self::Output {
FrameIndex::saturating_sub(self, rhs)
}
}
impl<T> SaturatingSub<T> for FrameIndex<T>
where
T: SaturatingSub<Output = T>,
{
type Output = Self;
#[inline]
fn saturating_sub(self, rhs: T) -> Self::Output {
FrameIndex::saturating_sub_t(self, rhs)
}
}