pub trait IsClose<Rhs = Self> {
type Tolerance;
const ZERO_TOL: Self::Tolerance;
const ABS_TOL: Self::Tolerance;
const REL_TOL: Self::Tolerance;
// Required method
fn is_close_tol(
&self,
rhs: &Rhs,
rel_tol: &Self::Tolerance,
abs_tol: &Self::Tolerance,
) -> bool;
// Provided methods
fn is_close(&self, rhs: &Rhs) -> bool { ... }
fn is_close_rel_tol(&self, rhs: &Rhs, rel_tol: &Self::Tolerance) -> bool { ... }
fn is_close_abs_tol(&self, rhs: &Rhs, abs_tol: &Self::Tolerance) -> bool { ... }
}Expand description
Trait used for testing if floating point values are approximately equal
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn is_close_tol(
&self,
rhs: &Rhs,
rel_tol: &Self::Tolerance,
abs_tol: &Self::Tolerance,
) -> bool
fn is_close_tol( &self, rhs: &Rhs, rel_tol: &Self::Tolerance, abs_tol: &Self::Tolerance, ) -> bool
Check if two values are approximately equal using the given relative and absolute tolerances.
This is the only function that must be reimplemented to implement the
IsClose trait for foreign types.
Provided Methods§
Sourcefn is_close(&self, rhs: &Rhs) -> bool
fn is_close(&self, rhs: &Rhs) -> bool
Check if two values are approximately equal. This is equivalent to
calling IsClose::is_close_tol with IsClose::REL_TOL and
IsClose::ABS_TOL as the respective tolerance arguments.
Note: When implementing IsClose for foreign types the default
implementation of IsClose::is_close should almost never be
overridden. Instead, you should implement IsClose::is_close_tol
which this function delegates to.
Sourcefn is_close_rel_tol(&self, rhs: &Rhs, rel_tol: &Self::Tolerance) -> bool
fn is_close_rel_tol(&self, rhs: &Rhs, rel_tol: &Self::Tolerance) -> bool
Check if two values are approximately equal using the given relative
tolerance. This is equivalent to calling IsClose::is_close_tol with
an absolute tolerance of 0.0.
Note: When implementing IsClose for foreign types the default
implementation of IsClose::is_close_rel_tol should almost never be
overridden. Instead, you should implement IsClose::is_close_tol
which this function delegates to.
Sourcefn is_close_abs_tol(&self, rhs: &Rhs, abs_tol: &Self::Tolerance) -> bool
fn is_close_abs_tol(&self, rhs: &Rhs, abs_tol: &Self::Tolerance) -> bool
Check if two values are approximately equal using the given absolute
tolerance. This is equivalent to calling IsClose::is_close_tol with
an relative tolerance of 0.0.
Note: When implementing IsClose for foreign types the default
implementation of IsClose::is_close_abs_tol should almost never be
overridden. Instead, you should implement IsClose::is_close_tol
which this function delegates to.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".