use super::basic::{B0, B1, Z0, P1, N1, NonZero, NonOne};
use crate::variable::{Var,Numeric};
pub trait Sub1 {
type Output;
fn sub1(self) -> Self::Output;
}
impl Sub1 for Z0 {
type Output = N1;
#[inline(always)]
fn sub1(self) -> Self::Output{
N1::new()
}
}
impl Sub1 for P1 {
type Output = Z0;
#[inline(always)]
fn sub1(self) -> Self::Output{
Z0::new()
}
}
impl Sub1 for N1 {
type Output = B0<N1>;
#[inline(always)]
fn sub1(self) -> Self::Output{
B0::new()
}
}
impl<H: NonZero + NonOne + Sub1> Sub1 for B0<H>{ type Output = B1<H::Output>;
#[inline(always)]
fn sub1(self) -> Self::Output{
B1::new()
}
}
impl<H: NonZero + NonOne> Sub1 for B1<H>{ type Output = B0<H>;
#[inline(always)]
fn sub1(self) -> Self::Output{
B0::new()
}
}
impl Sub1 for B1<P1>{
type Output = B0<P1>;
#[inline(always)]
fn sub1(self) -> Self::Output{
B0::new()
}
}
impl Sub1 for B0<P1>{
type Output = P1;
#[inline(always)]
fn sub1(self) -> Self::Output{
P1::new()
}
}
#[allow(dead_code)]
pub type SubOne<I> = <I as Sub1>::Output;
impl<T:Numeric> Sub1 for Var<T> {
type Output = Self;
#[inline(always)]
fn sub1(self) -> Self::Output{
Self(self.0 - 1.into())
}
}