pub struct Ulps<'a, T>where
T: 'a + ApproxEq,{
pub lhs: &'a T,
pub rhs: &'a T,
pub epsilon: <T as ApproxEq>::Epsilon,
pub max_ulps: u32,
}
Expand description
The requisite parameters for testing for approximate equality.
Fields§
§lhs: &'a T
The left-hand side of the approximate equality comparison.
rhs: &'a T
The right-hand side of the approximate equality comparison.
epsilon: <T as ApproxEq>::Epsilon
The tolerance to use when testing values that are close together.
max_ulps: u32
The ULPs to tolerate when testing values that are far-apart.
Implementations§
source§impl<'a, T> Ulps<'a, T>where
T: ApproxEq,
impl<'a, T> Ulps<'a, T>where T: ApproxEq,
sourcepub fn new(lhs: &'a T, rhs: &'a T) -> Ulps<'a, T>
pub fn new(lhs: &'a T, rhs: &'a T) -> Ulps<'a, T>
The beginning of a chained equality expression, using an ULPs based comparison.
use std::f64;
use approx::Ulps;
Ulps::new(&1.0, &1.0).eq();
Ulps::new(&1.0, &1.0).epsilon(f64::EPSILON).eq();
Ulps::new(&1.0, &1.0).max_ulps(4).eq();
Ulps::new(&1.0, &1.0).epsilon(f64::EPSILON).max_ulps(4).eq();
Ulps::new(&1.0, &1.0).max_ulps(4).epsilon(f64::EPSILON).eq();
sourcepub fn epsilon(self, epsilon: <T as ApproxEq>::Epsilon) -> Ulps<'a, T>
pub fn epsilon(self, epsilon: <T as ApproxEq>::Epsilon) -> Ulps<'a, T>
Replace the epsilon value with the one specified.
Auto Trait Implementations§
impl<'a, T> RefUnwindSafe for Ulps<'a, T>where T: RefUnwindSafe, <T as ApproxEq>::Epsilon: RefUnwindSafe,
impl<'a, T> Send for Ulps<'a, T>where T: Sync, <T as ApproxEq>::Epsilon: Send,
impl<'a, T> Sync for Ulps<'a, T>where T: Sync, <T as ApproxEq>::Epsilon: Sync,
impl<'a, T> Unpin for Ulps<'a, T>where <T as ApproxEq>::Epsilon: Unpin,
impl<'a, T> UnwindSafe for Ulps<'a, T>where T: RefUnwindSafe, <T as ApproxEq>::Epsilon: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more