pub trait Approx: HasXY {
// Required methods
fn is_ulps_eq(
self,
other: Self,
epsilon: <Self::Scalar as AbsDiffEq>::Epsilon,
max_ulps: u32,
) -> bool;
fn is_abs_diff_eq(
self,
other: Self,
epsilon: <Self::Scalar as AbsDiffEq>::Epsilon,
) -> bool;
}Expand description
A workaround for Rust’s limitations where external traits cannot be implemented for external types.
The Approx trait provides methods for performing approximate equality comparisons on types.
It serves as a workaround for Rust’s limitations, allowing you to implement approximate
equality checks for types not originally designed with this capability.
This trait leverages the approx crate and its traits to perform approximate equality
comparisons. The methods in this trait are wrappers around the corresponding methods provided
by the approx crate.
Required Methods§
Sourcefn is_ulps_eq(
self,
other: Self,
epsilon: <Self::Scalar as AbsDiffEq>::Epsilon,
max_ulps: u32,
) -> bool
fn is_ulps_eq( self, other: Self, epsilon: <Self::Scalar as AbsDiffEq>::Epsilon, max_ulps: u32, ) -> bool
Checks if two instances are nearly equal within a specified tolerance in ULPs (Units in the Last Place).
This method delegates to the approx::UlpsEq::ulps_eq method, performing approximate equality checks
one time per coordinate axis.
Sourcefn is_abs_diff_eq(
self,
other: Self,
epsilon: <Self::Scalar as AbsDiffEq>::Epsilon,
) -> bool
fn is_abs_diff_eq( self, other: Self, epsilon: <Self::Scalar as AbsDiffEq>::Epsilon, ) -> bool
Checks if two instances are nearly equal within a specified absolute difference tolerance.
This method delegates to the approx::AbsDiffEq::abs_diff_eq method, performing approximate equality checks
one time per coordinate axis.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.