pub struct IsClosePredicate { /* private fields */ }
Expand description
Predicate that ensures two numbers are “close” enough, understanding that rounding errors occur.
This is created by the predicate::float::is_close
.
Implementations§
Source§impl IsClosePredicate
impl IsClosePredicate
Sourcepub fn distance(self, distance: <f64 as Ulps>::U) -> Self
pub fn distance(self, distance: <f64 as Ulps>::U) -> Self
Set the amount of error allowed.
Values 1
-5
should work in most cases. Sometimes more control is needed and you will
need to set IsClosePredicate::epsilon
separately from IsClosePredicate::ulps
.
§Examples
use predicates::prelude::*;
let a = 0.15_f64 + 0.15_f64 + 0.15_f64;
let predicate_fn = predicate::float::is_close(a).distance(5);
Sourcepub fn epsilon(self, epsilon: f64) -> Self
pub fn epsilon(self, epsilon: f64) -> Self
Set the absolute deviation allowed.
This is meant to handle problems near 0
. Values 1.
-5.
epislons should work in most
cases.
§Examples
use predicates::prelude::*;
let a = 0.15_f64 + 0.15_f64 + 0.15_f64;
let predicate_fn = predicate::float::is_close(a).epsilon(5.0 * ::std::f64::EPSILON);
Sourcepub fn ulps(self, ulps: <f64 as Ulps>::U) -> Self
pub fn ulps(self, ulps: <f64 as Ulps>::U) -> Self
Set the relative deviation allowed.
This is meant to handle large numbers. Values 1
-5
should work in most cases.
§Examples
use predicates::prelude::*;
let a = 0.15_f64 + 0.15_f64 + 0.15_f64;
let predicate_fn = predicate::float::is_close(a).ulps(5);
Trait Implementations§
Source§impl Clone for IsClosePredicate
impl Clone for IsClosePredicate
Source§fn clone(&self) -> IsClosePredicate
fn clone(&self) -> IsClosePredicate
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for IsClosePredicate
impl Debug for IsClosePredicate
Source§impl Display for IsClosePredicate
impl Display for IsClosePredicate
Source§impl PartialEq for IsClosePredicate
impl PartialEq for IsClosePredicate
Source§impl Predicate<f64> for IsClosePredicate
impl Predicate<f64> for IsClosePredicate
impl Copy for IsClosePredicate
impl StructuralPartialEq for IsClosePredicate
Auto Trait Implementations§
impl Freeze for IsClosePredicate
impl RefUnwindSafe for IsClosePredicate
impl Send for IsClosePredicate
impl Sync for IsClosePredicate
impl Unpin for IsClosePredicate
impl UnwindSafe for IsClosePredicate
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<P, Item> PredicateBooleanExt<Item> for P
impl<P, Item> PredicateBooleanExt<Item> for P
Source§fn and<B>(self, other: B) -> AndPredicate<Self, B, Item>
fn and<B>(self, other: B) -> AndPredicate<Self, B, Item>
Compute the logical AND of two
Predicate
results, returning the result. Read moreSource§fn or<B>(self, other: B) -> OrPredicate<Self, B, Item>
fn or<B>(self, other: B) -> OrPredicate<Self, B, Item>
Compute the logical OR of two
Predicate
results, returning the result. Read more