use super::basic::{Z0, P1, N1, B0, B1, NonZero, NonNegOne};
use crate::variable::{Var,Numeric};
pub trait Add1 {
type Output;
fn add1(self) -> Self::Output;
}
impl Add1 for Z0 {
type Output = P1; #[inline(always)]
fn add1(self) -> Self::Output{
P1::new()
}
}
impl Add1 for P1 {
type Output = B0<P1>;
#[inline(always)]
fn add1(self) -> Self::Output{
B0::new()
}
}
impl Add1 for N1 {
type Output = Z0;
#[inline(always)]
fn add1(self) -> Self::Output{
Z0::new()
}
}
impl<H:NonZero + NonNegOne> Add1 for B0<H>{ type Output = B1<H>;
#[inline(always)]
fn add1(self) -> Self::Output{
B1::new()
}
}
impl<H:NonZero + NonNegOne + Add1> Add1 for B1<H>{ type Output = B0<H::Output>;
#[inline(always)]
fn add1(self) -> Self::Output{
B0::new()
}
}
impl Add1 for B0<N1> {
type Output = N1;
#[inline(always)]
fn add1(self) -> Self::Output{
N1::new()
}
}
pub type AddOne<A> = <A as Add1>::Output;
impl<T:Numeric> Add1 for Var<T> {
type Output = Self;
#[inline(always)]
fn add1(self) -> Self::Output{
Self(self.0 + 1.into())
}
}