Struct approx::Relative [−][src]
pub struct Relative<T: RelativeEq + ?Sized> { pub epsilon: T::Epsilon, pub max_relative: T::Epsilon, }
The requisite parameters for testing for approximate equality using a relative based comparison.
This is not normally used directly, rather via the
assert_relative_{eq|ne}!
and relative_{eq|ne}!
macros.
Example
use std::f64; use approx::Relative; Relative::default().eq(&1.0, &1.0); Relative::default().epsilon(f64::EPSILON).eq(&1.0, &1.0); Relative::default().max_relative(1.0).eq(&1.0, &1.0); Relative::default().epsilon(f64::EPSILON).max_relative(1.0).eq(&1.0, &1.0); Relative::default().max_relative(1.0).epsilon(f64::EPSILON).eq(&1.0, &1.0);
Fields
epsilon: T::Epsilon
The tolerance to use when testing values that are close together.
max_relative: T::Epsilon
The relative tolerance for testing values that are far-apart.
Methods
impl<T: RelativeEq + ?Sized> Relative<T>
[src]
impl<T: RelativeEq + ?Sized> Relative<T>
pub fn epsilon(self, epsilon: T::Epsilon) -> Relative<T>
[src]
pub fn epsilon(self, epsilon: T::Epsilon) -> Relative<T>
Replace the epsilon value with the one specified.
pub fn max_relative(self, max_relative: T::Epsilon) -> Relative<T>
[src]
pub fn max_relative(self, max_relative: T::Epsilon) -> Relative<T>
Replace the maximum relative value with the one specified.
pub fn eq(self, lhs: &T, rhs: &T) -> bool
[src]
pub fn eq(self, lhs: &T, rhs: &T) -> bool
Peform the equality comparison
pub fn ne(self, lhs: &T, rhs: &T) -> bool
[src]
pub fn ne(self, lhs: &T, rhs: &T) -> bool
Peform the inequality comparison
Trait Implementations
impl<T: RelativeEq + ?Sized> Default for Relative<T>
[src]
impl<T: RelativeEq + ?Sized> Default for Relative<T>