AbsDiffEq in approx - Rust
Description: Equality that is defined using the absolute difference of two numbers.
Keywords: rust, rustlang, rust-lang, AbsDiffEq

# Trait approx::AbsDiffEq

source ·

    pub trait AbsDiffEq<Rhs = Self>: PartialEq<Rhs>where
        Rhs: ?Sized,{
        type Epsilon;

        fn default_epsilon() -> Self::Epsilon;
        fn abs_diff_eq(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool;

        fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool { ... }
    }

Expand description

Equality that is defined using the absolute difference of two numbers.

## Required Associated Types§

source

#### type Epsilon

Used for specifying relative comparisons.

## Required Methods§

source

#### fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together.

This is used when no `epsilon` value is supplied to the [`abs_diff_eq!`], [`relative_eq!`], or [`ulps_eq!`] macros.

source

#### fn abs_diff_eq(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.

## Provided Methods§

source

#### fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of `AbsDiffEq::abs_diff_eq`.

## Implementations on Foreign Types§

source§

### impl AbsDiffEq<u8> for u8

§

#### type Epsilon = u8

source§

#### fn default_epsilon() -> u8

source§

#### fn abs_diff_eq(&self, other: &u8, epsilon: u8) -> bool

source§

### impl AbsDiffEq<u16> for u16

§

#### type Epsilon = u16

source§

#### fn default_epsilon() -> u16

source§

#### fn abs_diff_eq(&self, other: &u16, epsilon: u16) -> bool

source§

### impl AbsDiffEq<u32> for u32

§

#### type Epsilon = u32

source§

#### fn default_epsilon() -> u32

source§

#### fn abs_diff_eq(&self, other: &u32, epsilon: u32) -> bool

source§

### impl AbsDiffEq<u64> for u64

§

#### type Epsilon = u64

source§

#### fn default_epsilon() -> u64

source§

#### fn abs_diff_eq(&self, other: &u64, epsilon: u64) -> bool

source§

### impl AbsDiffEq<usize> for usize

§

#### type Epsilon = usize

source§

#### fn default_epsilon() -> usize

source§

#### fn abs_diff_eq(&self, other: &usize, epsilon: usize) -> bool

source§

### impl AbsDiffEq<i8> for i8

§

#### type Epsilon = i8

source§

#### fn default_epsilon() -> i8

source§

#### fn abs_diff_eq(&self, other: &i8, epsilon: i8) -> bool

source§

### impl AbsDiffEq<i16> for i16

§

#### type Epsilon = i16

source§

#### fn default_epsilon() -> i16

source§

#### fn abs_diff_eq(&self, other: &i16, epsilon: i16) -> bool

source§

### impl AbsDiffEq<i32> for i32

§

#### type Epsilon = i32

source§

#### fn default_epsilon() -> i32

source§

#### fn abs_diff_eq(&self, other: &i32, epsilon: i32) -> bool

source§

### impl AbsDiffEq<i64> for i64

§

#### type Epsilon = i64

source§

#### fn default_epsilon() -> i64

source§

#### fn abs_diff_eq(&self, other: &i64, epsilon: i64) -> bool

source§

### impl AbsDiffEq<isize> for isize

§

#### type Epsilon = isize

source§

#### fn default_epsilon() -> isize

source§

#### fn abs_diff_eq(&self, other: &isize, epsilon: isize) -> bool

source§

### impl AbsDiffEq<f32> for f32

§

#### type Epsilon = f32

source§

#### fn default_epsilon() -> f32

source§

#### fn abs_diff_eq(&self, other: &f32, epsilon: f32) -> bool

source§

### impl AbsDiffEq<f64> for f64

§

#### type Epsilon = f64

source§

#### fn default_epsilon() -> f64

source§

#### fn abs_diff_eq(&self, other: &f64, epsilon: f64) -> bool

source§

### impl<'a, T: AbsDiffEq + ?Sized> AbsDiffEq<&'a T> for &'a T

§

#### type Epsilon = <T as AbsDiffEq<T>>::Epsilon

source§

#### fn default_epsilon() -> T::Epsilon

source§

#### fn abs_diff_eq(&self, other: &&'a T, epsilon: T::Epsilon) -> bool

source§

### impl<'a, T: AbsDiffEq + ?Sized> AbsDiffEq<&'a mut T> for &'a mut T

§

#### type Epsilon = <T as AbsDiffEq<T>>::Epsilon

source§

#### fn default_epsilon() -> T::Epsilon

source§

#### fn abs_diff_eq(&self, other: &&'a mut T, epsilon: T::Epsilon) -> bool

source§

### impl<T: AbsDiffEq + Copy> AbsDiffEq<Cell<T>> for Cell<T>

§

#### type Epsilon = <T as AbsDiffEq<T>>::Epsilon

source§

#### fn default_epsilon() -> T::Epsilon

source§

#### fn abs_diff_eq(&self, other: &Cell<T>, epsilon: T::Epsilon) -> bool

source§

### impl<T: AbsDiffEq + ?Sized> AbsDiffEq<RefCell<T>> for RefCell<T>

§

#### type Epsilon = <T as AbsDiffEq<T>>::Epsilon

source§

#### fn default_epsilon() -> T::Epsilon

source§

#### fn abs_diff_eq(&self, other: &RefCell<T>, epsilon: T::Epsilon) -> bool

source§

### impl<A, B> AbsDiffEq<[B]> for [A]where
A: AbsDiffEq<B>,
A::Epsilon: Clone,

§

#### type Epsilon = <A as AbsDiffEq<B>>::Epsilon

source§

#### fn default_epsilon() -> A::Epsilon

source§

#### fn abs_diff_eq(&self, other: &[B], epsilon: A::Epsilon) -> bool

## Implementors§