use core::fmt;
pub trait FloatEqUlpsTol {
type UlpsTol: ?Sized;
}
pub type UlpsTol<T> = <T as FloatEqUlpsTol>::UlpsTol;
pub trait FloatEqDebugUlpsDiff {
type DebugUlpsDiff;
}
pub type DebugUlpsDiff<T> = <T as FloatEqDebugUlpsDiff>::DebugUlpsDiff;
pub trait FloatEq<Rhs: ?Sized = Self> {
type Tol: ?Sized + FloatEqUlpsTol;
fn eq_abs(&self, other: &Rhs, tol: &Self::Tol) -> bool;
#[inline]
fn ne_abs(&self, other: &Rhs, tol: &Self::Tol) -> bool {
!self.eq_abs(other, tol)
}
#[inline]
fn eq_rel(&self, other: &Rhs, tol: &Self::Tol) -> bool {
self.eq_rmax(other, tol)
}
#[inline]
fn ne_rel(&self, other: &Rhs, tol: &Self::Tol) -> bool {
!self.eq_rel(other, tol)
}
fn eq_rmax(&self, other: &Rhs, tol: &Self::Tol) -> bool;
#[inline]
fn ne_rmax(&self, other: &Rhs, tol: &Self::Tol) -> bool {
!self.eq_rmax(other, tol)
}
fn eq_rmin(&self, other: &Rhs, tol: &Self::Tol) -> bool;
#[inline]
fn ne_rmin(&self, other: &Rhs, tol: &Self::Tol) -> bool {
!self.eq_rmin(other, tol)
}
fn eq_r1st(&self, other: &Rhs, tol: &Self::Tol) -> bool;
#[inline]
fn ne_r1st(&self, other: &Rhs, tol: &Self::Tol) -> bool {
!self.eq_r1st(other, tol)
}
fn eq_r2nd(&self, other: &Rhs, tol: &Self::Tol) -> bool;
#[inline]
fn ne_r2nd(&self, other: &Rhs, tol: &Self::Tol) -> bool {
!self.eq_r2nd(other, tol)
}
fn eq_ulps(&self, other: &Rhs, tol: &UlpsTol<Self::Tol>) -> bool;
#[inline]
fn ne_ulps(&self, other: &Rhs, tol: &UlpsTol<Self::Tol>) -> bool {
!self.eq_ulps(other, tol)
}
}
pub trait FloatEqAll<Rhs: ?Sized = Self> {
type AllTol: ?Sized + FloatEqUlpsTol;
fn eq_abs_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool;
#[inline]
fn ne_abs_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
!self.eq_abs_all(other, tol)
}
#[inline]
fn eq_rel_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
self.eq_rmax_all(other, tol)
}
#[inline]
fn ne_rel_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
!self.eq_rel_all(other, tol)
}
fn eq_rmax_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool;
#[inline]
fn ne_rmax_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
!self.eq_rmax_all(other, tol)
}
fn eq_rmin_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool;
#[inline]
fn ne_rmin_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
!self.eq_rmin_all(other, tol)
}
fn eq_r1st_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool;
#[inline]
fn ne_r1st_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
!self.eq_r1st_all(other, tol)
}
fn eq_r2nd_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool;
#[inline]
fn ne_r2nd_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool {
!self.eq_r2nd_all(other, tol)
}
fn eq_ulps_all(&self, other: &Rhs, tol: &UlpsTol<Self::AllTol>) -> bool;
#[inline]
fn ne_ulps_all(&self, other: &Rhs, tol: &UlpsTol<Self::AllTol>) -> bool {
!self.eq_ulps_all(other, tol)
}
}
pub trait AssertFloatEq<Rhs: ?Sized = Self>: FloatEq<Rhs> {
type DebugAbsDiff: fmt::Debug + Sized + FloatEqDebugUlpsDiff;
type DebugTol: fmt::Debug + FloatEqUlpsTol;
fn debug_abs_diff(&self, other: &Rhs) -> Self::DebugAbsDiff;
fn debug_ulps_diff(&self, other: &Rhs) -> DebugUlpsDiff<Self::DebugAbsDiff>;
fn debug_abs_tol(&self, other: &Rhs, tol: &Self::Tol) -> Self::DebugTol;
#[inline]
fn debug_rel_tol(&self, other: &Rhs, tol: &Self::Tol) -> Self::DebugTol {
self.debug_rmax_tol(other, tol)
}
fn debug_rmax_tol(&self, other: &Rhs, tol: &Self::Tol) -> Self::DebugTol;
fn debug_rmin_tol(&self, other: &Rhs, tol: &Self::Tol) -> Self::DebugTol;
fn debug_r1st_tol(&self, other: &Rhs, tol: &Self::Tol) -> Self::DebugTol;
fn debug_r2nd_tol(&self, other: &Rhs, tol: &Self::Tol) -> Self::DebugTol;
fn debug_ulps_tol(&self, other: &Rhs, tol: &UlpsTol<Self::Tol>) -> UlpsTol<Self::DebugTol>
where
UlpsTol<Self::DebugTol>: Sized;
}
pub trait AssertFloatEqAll<Rhs: ?Sized = Self>: FloatEqAll<Rhs> {
type AllDebugTol: fmt::Debug + FloatEqUlpsTol;
fn debug_abs_all_tol(&self, other: &Rhs, tol: &Self::AllTol) -> Self::AllDebugTol;
#[inline]
fn debug_rel_all_tol(&self, other: &Rhs, tol: &Self::AllTol) -> Self::AllDebugTol {
self.debug_rmax_all_tol(other, tol)
}
fn debug_rmax_all_tol(&self, other: &Rhs, tol: &Self::AllTol) -> Self::AllDebugTol;
fn debug_rmin_all_tol(&self, other: &Rhs, tol: &Self::AllTol) -> Self::AllDebugTol;
fn debug_r1st_all_tol(&self, other: &Rhs, tol: &Self::AllTol) -> Self::AllDebugTol;
fn debug_r2nd_all_tol(&self, other: &Rhs, tol: &Self::AllTol) -> Self::AllDebugTol;
fn debug_ulps_all_tol(
&self,
other: &Rhs,
tol: &UlpsTol<Self::AllTol>,
) -> UlpsTol<Self::AllDebugTol>
where
UlpsTol<Self::AllDebugTol>: Sized;
}