use core::ops::{Add, AddAssign, Sub, SubAssign};
use crate::{Duration, Time};
impl<T> Sub for Time<T>
where
T: Sub<Output = T>,
{
type Output = Duration<T>;
#[inline]
fn sub(self, rhs: Self) -> Self::Output {
Duration(self.0 - rhs.0)
}
}
impl<T> Sub<T> for Time<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 Time<T>
where
T: SubAssign,
{
#[inline]
fn sub_assign(&mut self, rhs: T) {
self.0 -= rhs;
}
}
impl<T> Add<Duration<T>> for Time<T>
where
T: Add<Output = T>,
{
type Output = Self;
#[inline]
fn add(self, rhs: Duration<T>) -> Self::Output {
Self(self.0 + rhs.0)
}
}
impl<T> AddAssign<Duration<T>> for Time<T>
where
T: AddAssign,
{
#[inline]
fn add_assign(&mut self, rhs: Duration<T>) {
self.0 += rhs.0;
}
}
impl<T> Sub<Duration<T>> for Time<T>
where
T: Sub<Output = T>,
{
type Output = Self;
#[inline]
fn sub(self, rhs: Duration<T>) -> Self::Output {
Self(self.0 - rhs.0)
}
}
impl<T> SubAssign<Duration<T>> for Time<T>
where
T: SubAssign,
{
#[inline]
fn sub_assign(&mut self, rhs: Duration<T>) {
self.0 -= rhs.0;
}
}