Struct predicates::float::IsClosePredicate[][src]

pub struct IsClosePredicate { /* fields omitted */ }

Predicate that ensures two numbers are "close" enough, understanding that rounding errors occur.

This is created by the predicate::float::is_close.

Implementations

impl IsClosePredicate[src]

pub fn distance(mut self: Self, distance: <f64 as Ulps>::U) -> Self[src]

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);

pub fn epsilon(mut self: Self, epsilon: f64) -> Self[src]

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);

pub fn ulps(mut self: Self, ulps: <f64 as Ulps>::U) -> Self[src]

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

impl Clone for IsClosePredicate[src]

impl Copy for IsClosePredicate[src]

impl Debug for IsClosePredicate[src]

impl Display for IsClosePredicate[src]

impl PartialEq<IsClosePredicate> for IsClosePredicate[src]

impl Predicate<f64> for IsClosePredicate[src]

impl PredicateReflection for IsClosePredicate[src]

impl StructuralPartialEq for IsClosePredicate[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<P, Item> PredicateBooleanExt<Item> for P where
    Item: ?Sized,
    P: Predicate<Item>, 
[src]

impl<P, Item> PredicateNameExt<Item> for P where
    Item: ?Sized,
    P: Predicate<Item>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.