FloatEqAll

Trait FloatEqAll 

Source
pub trait FloatEqAll<Rhs: ?Sized = Self> {
    type AllTol: ?Sized + FloatEqUlpsTol;

Show 14 methods // Required methods fn eq_abs_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool; fn eq_rmax_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool; fn eq_rmin_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool; fn eq_r1st_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool; fn eq_r2nd_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool; fn eq_ulps_all(&self, other: &Rhs, tol: &UlpsTol<Self::AllTol>) -> bool; // Provided methods fn ne_abs_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn eq_rel_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn ne_rel_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn ne_rmax_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn ne_rmin_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn ne_r1st_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn ne_r2nd_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool { ... } fn ne_ulps_all(&self, other: &Rhs, tol: &UlpsTol<Self::AllTol>) -> bool { ... }
}
Expand description

Compare IEEE floating point values for equality using a uniform tolerance.

This trait is used in the implementation of the float_eq! and assert_float_eq! families of macros to provide the *_all variants of comparison algorithms for homogeneous types.

To implement this trait over a new type, see How to compare custom types.

§Examples

let a = [1.000_000_2f32, -2.0];
let b = [1.0f32, -2.000_002];

assert!(a.eq_abs_all(&b, &0.000_002));
assert!(a.ne_abs_all(&b, &0.000_001));

assert!(a.eq_rmax_all(&b, &0.000_001));
assert!(a.ne_rmax_all(&b, &0.000_000_5));

assert!(a.eq_ulps_all(&b, &8));
assert!(a.ne_ulps_all(&b, &7));

Required Associated Types§

Source

type AllTol: ?Sized + FloatEqUlpsTol

Type of the maximum allowed difference between each of two values’ fields for them to be considered equal.

Required Methods§

Source

fn eq_abs_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is equal to other, using an absolute tolerance comparison.

This must use the same algorithm as FloatEq::eq_abs.

Source

fn eq_rmax_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is equal to other, using a relative tolerance comparison.

This must use the same algorithm as FloatEq::eq_rmax.

Source

fn eq_rmin_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is equal to other, using a relative tolerance comparison.

This must use the same algorithm as FloatEq::eq_rmin.

Source

fn eq_r1st_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is equal to other, using a relative tolerance comparison.

This must use the same algorithm as FloatEq::eq_r1st.

Source

fn eq_r2nd_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is equal to other, using a relative tolerance comparison.

This must use the same algorithm as FloatEq::eq_r2nd.

Source

fn eq_ulps_all(&self, other: &Rhs, tol: &UlpsTol<Self::AllTol>) -> bool

Check whether self is equal to other, using an ULPs comparison.

This must use the same algorithm as FloatEq::eq_ulps.

Provided Methods§

Source

fn ne_abs_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is not equal to other, using an absolute tolerance comparison.

Equal to !self.eq_abs_all(other, tol), there is no need to reimplement this for your own types.

Source

fn eq_rel_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is equal to other, using a relative tolerance comparison.

Equal to self.eq_rmax_all(other, tol), there is no need to reimplement this for your own types.

Source

fn ne_rel_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is not equal to other, using a relative tolerance comparison.

Equal to !self.eq_rel_all(other, tol), there is no need to reimplement this for your own types.

Source

fn ne_rmax_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is not equal to other, using a relative tolerance comparison.

Equal to !self.eq_rmax_all(other, tol), there is no need to reimplement this for your own types.

Source

fn ne_rmin_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is not equal to other, using a relative tolerance comparison.

Equal to !self.eq_rmin_all(other, tol), there is no need to reimplement this for your own types.

Source

fn ne_r1st_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is not equal to other, using a relative tolerance comparison.

Equal to !self.eq_r1st_all(other, tol), there is no need to reimplement this for your own types.

Source

fn ne_r2nd_all(&self, other: &Rhs, tol: &Self::AllTol) -> bool

Check whether self is not equal to other, using a relative tolerance comparison.

Equal to !self.eq_r2nd_all(other, tol), there is no need to reimplement this for your own types.

Source

fn ne_ulps_all(&self, other: &Rhs, tol: &UlpsTol<Self::AllTol>) -> bool

Check whether self is not equal to other, using an ULPs comparison.

Equal to !self.eq_ulps_all(other, tol), there is no need to reimplement this for your own types.

Implementations on Foreign Types§

Source§

impl FloatEqAll for f32

Source§

type AllTol = f32

Source§

fn eq_abs_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Self, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl FloatEqAll for f64

Source§

type AllTol = f64

Source§

fn eq_abs_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Self, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B> FloatEqAll<[B]> for [A]
where A: FloatEqAll<B>,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &[B], tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &[B], tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &[B], tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &[B], tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &[B], tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &[B], tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B> FloatEqAll<LinkedList<B>> for LinkedList<A>
where A: FloatEqAll<B>,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &LinkedList<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &LinkedList<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &LinkedList<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &LinkedList<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &LinkedList<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all( &self, other: &LinkedList<B>, tol: &UlpsTol<Self::AllTol>, ) -> bool

Source§

impl<A, B> FloatEqAll<VecDeque<B>> for VecDeque<A>
where A: FloatEqAll<B>,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &VecDeque<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &VecDeque<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &VecDeque<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &VecDeque<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &VecDeque<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &VecDeque<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B> FloatEqAll<Vec<B>> for Vec<A>
where A: FloatEqAll<B>,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &Vec<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Vec<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Vec<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Vec<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Vec<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Vec<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B> FloatEqAll<Cell<B>> for Cell<A>
where A: FloatEqAll<B> + Copy, B: Copy,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &Cell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Cell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Cell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Cell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Cell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Cell<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B, const N: usize> FloatEqAll<[B; N]> for [A; N]
where A: FloatEqAll<B>,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &[B; N], tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &[B; N], tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &[B; N], tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &[B; N], tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &[B; N], tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &[B; N], tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<&B> for &A
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &&B, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<&B> for &mut A
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &&B, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &&B, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<&mut B> for &A
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &&mut B, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<&mut B> for &mut A
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &&mut B, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &&mut B, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<Box<B>> for Box<A>
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &Box<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Box<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Box<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Box<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Box<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Box<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<Rc<B>> for Rc<A>
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &Rc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Rc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Rc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Rc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Rc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Rc<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<Arc<B>> for Arc<A>
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &Arc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Arc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Arc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Arc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Arc<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Arc<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<A, B: ?Sized> FloatEqAll<RefCell<B>> for RefCell<A>
where A: FloatEqAll<B> + ?Sized,

Source§

type AllTol = <A as FloatEqAll<B>>::AllTol

Source§

fn eq_abs_all(&self, other: &RefCell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &RefCell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &RefCell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &RefCell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &RefCell<B>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &RefCell<B>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<K, VA, VB> FloatEqAll<BTreeMap<K, VB>> for BTreeMap<K, VA>
where K: Eq + Ord, VA: FloatEqAll<VB>,

Source§

type AllTol = <VA as FloatEqAll<VB>>::AllTol

Source§

fn eq_abs_all(&self, other: &BTreeMap<K, VB>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &BTreeMap<K, VB>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &BTreeMap<K, VB>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &BTreeMap<K, VB>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &BTreeMap<K, VB>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all( &self, other: &BTreeMap<K, VB>, tol: &UlpsTol<Self::AllTol>, ) -> bool

Source§

impl<K, VA, VB, S> FloatEqAll<HashMap<K, VB, S>> for HashMap<K, VA, S>
where K: Eq + Hash, S: BuildHasher, VA: FloatEqAll<VB>,

Source§

type AllTol = <VA as FloatEqAll<VB>>::AllTol

Source§

fn eq_abs_all(&self, other: &HashMap<K, VB, S>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &HashMap<K, VB, S>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &HashMap<K, VB, S>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &HashMap<K, VB, S>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &HashMap<K, VB, S>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all( &self, other: &HashMap<K, VB, S>, tol: &UlpsTol<Self::AllTol>, ) -> bool

Source§

impl<T: FloatEqAll> FloatEqAll for Option<T>
where T::AllTol: Sized, UlpsTol<T::AllTol>: Sized,

Source§

type AllTol = Option<<T as FloatEqAll>::AllTol>

Source§

fn eq_abs_all(&self, other: &Option<T>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Option<T>, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Option<T>, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Option<T>, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Option<T>, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Option<T>, tol: &UlpsTol<Self::AllTol>) -> bool

Source§

impl<T: FloatEqAll> FloatEqAll for Complex<T>

Source§

type AllTol = <T as FloatEqAll>::AllTol

Source§

fn eq_abs_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_rmax_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_rmin_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_r1st_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_r2nd_all(&self, other: &Self, tol: &Self::AllTol) -> bool

Source§

fn eq_ulps_all(&self, other: &Self, tol: &UlpsTol<Self::AllTol>) -> bool

Implementors§