use crate::{sf, Deref, DerefMut, NumError as E, NumResult as Result};
#[cfg(doc)]
use E::{NotImplemented, NotSupported};
mod impls;
sf! {
impl<T: Num> NumRef<'_> for &T { type Own = T; }
impl<T: Num> NumRef<'_> for &mut T { type Own = T; }
}
#[rustfmt::skip]
#[cfg_attr(feature = "nightly_doc", doc(notable_trait))]
#[allow(unused_variables, reason = "default implementation is not implemented")]
pub trait Num {
type Inner;
type Out;
type Rhs;
#[must_use]
fn num_into(self) -> Self::Inner;
fn num_from(value: Self::Inner) -> Result<Self>
where Self: Sized { E::ni() }
fn num_from_ref(value: &Self::Inner) -> Result<Self>
where Self: Sized { E::ni() }
fn num_set(&mut self, value: Self::Inner) -> Result<()> { E::ni() }
fn num_set_ref(&mut self, value: &Self::Inner) -> Result<()> { E::ni() }
fn num_is_zero(&self) -> Result<bool> { E::ni() }
fn num_get_zero() -> Result<Self> where Self: Sized { E::ni() }
fn num_set_zero(&mut self) -> Result<()> { E::ni() }
fn num_is_one(&self) -> Result<bool> { E::ni() }
fn num_get_one() -> Result<Self> where Self: Sized { E::ni() }
fn num_set_one(&mut self) -> Result<()> { E::ni() }
fn num_add(self, rhs: Self::Rhs) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_add(&self, rhs: &Self::Rhs) -> Result<Self::Out> { E::ni() }
fn num_ref_add_assign(&mut self, rhs: &Self::Rhs) -> Result<()> { E::ni() }
fn num_sub(self, rhs: Self::Rhs) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_sub(&self, rhs: &Self::Rhs) -> Result<Self::Out> { E::ni() }
fn num_ref_sub_assign(&mut self, rhs: &Self::Rhs) -> Result<()> { E::ni() }
fn num_mul(self, rhs: Self::Rhs) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_mul(&self, rhs: &Self::Rhs) -> Result<Self::Out> { E::ni() }
fn num_ref_mul_assign(&mut self, rhs: &Self::Rhs) -> Result<()> { E::ni() }
fn num_div(self, rhs: Self::Rhs) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_div(&self, rhs: &Self::Rhs) -> Result<Self::Out> { E::ni() }
fn num_ref_div_assign(&mut self, rhs: &Self::Rhs) -> Result<()> { E::ni() }
fn num_rem(self, rhs: Self::Rhs) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_rem(&self, rhs: &Self::Rhs) -> Result<Self::Out> { E::ni() }
fn num_ref_rem_assign(&mut self, rhs: &Self::Rhs) -> Result<()> { E::ni() }
fn num_neg(self) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_neg(&self) -> Result<Self::Out> { E::ni() }
fn num_abs(self) -> Result<Self::Out> where Self: Sized { E::ni() }
fn num_ref_abs(&self) -> Result<Self::Out> { E::ni() }
}
#[rustfmt::skip]
#[cfg_attr(feature = "nightly_doc", doc(notable_trait))]
pub trait NumRef<'a> where Self: Deref<Target = Self::Own> {
type Own: Num;
fn num_to_owned(&self) -> Result<Self::Own> where Self::Own: Clone { Ok((*self).clone()) }
fn num_set(&mut self, value: <Self::Own as Num>::Inner) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_set(value) }
fn num_set_ref(&mut self, value: &<Self::Own as Num>::Inner) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_set_ref(value) }
fn num_is_zero(&self) -> Result<bool> { self.deref().num_is_zero() }
fn num_get_zero() -> Result<Self::Own> { Self::Own::num_get_zero() }
fn num_set_zero(&mut self) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_set_zero() }
fn num_is_one(&self) -> Result<bool> { self.deref().num_is_one() }
fn num_get_one() -> Result<Self::Own> { Self::Own::num_get_one() }
fn num_set_one(&mut self) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_set_one() }
fn num_ref_add(&self, rhs: &<Self::Own as Num>::Rhs) -> Result<<Self::Own as Num>::Out> {
self.deref().num_ref_add(rhs) }
fn num_ref_add_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_ref_add_assign(rhs) }
fn num_ref_sub(&self, rhs: &<Self::Own as Num>::Rhs) -> Result<<Self::Own as Num>::Out> {
self.deref().num_ref_sub(rhs) }
fn num_ref_sub_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_ref_sub_assign(rhs) }
fn num_ref_mul(&self, rhs: &<Self::Own as Num>::Rhs) -> Result<<Self::Own as Num>::Out> {
self.deref().num_ref_mul(rhs) }
fn num_ref_mul_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_ref_mul_assign(rhs) }
fn num_ref_div(&self, rhs: &<Self::Own as Num>::Rhs) -> Result<<Self::Own as Num>::Out> {
self.deref().num_ref_div(rhs) }
fn num_ref_div_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_ref_div_assign(rhs) }
fn num_ref_rem(&self, rhs: &<Self::Own as Num>::Rhs) -> Result<<Self::Own as Num>::Out> {
self.deref().num_ref_rem(rhs) }
fn num_ref_rem_assign(&mut self, rhs: &<Self::Own as Num>::Rhs) -> Result<()>
where Self: DerefMut<Target = Self::Own> { self.deref_mut().num_ref_rem_assign(rhs) }
fn num_ref_neg(&self) -> Result<<Self::Own as Num>::Out> { self.deref().num_ref_neg() }
fn num_ref_abs(&self) -> Result<<Self::Own as Num>::Out> { self.deref().num_ref_abs() }
}