[go: up one dir, main page]

Trait ApproxEq

Source
pub trait ApproxEq {
    type Eps: Sized;

    // Required methods
    fn default_epsilon() -> Self::Eps;
    fn approx_eq_eps(&self, b: &Self, epsilon: &Self::Eps) -> bool;

    // Provided method
    fn approx_eq(&self, b: &Self) -> bool { ... }
}
Expand description

A type with an approximate equivalence relation.

Required Associated Types§

Source

type Eps: Sized

The epsilon type used measure an error.

Required Methods§

Source

fn default_epsilon() -> Self::Eps

The default epsilon value to use in ApproxEq::approx_eq.

Source

fn approx_eq_eps(&self, b: &Self, epsilon: &Self::Eps) -> bool

Compare a and b for approximate equality using the specified epsilon value.

Provided Methods§

Source

fn approx_eq(&self, b: &Self) -> bool

Compare a and b for approximate equality using the default epsilon value returned by ApproxEq::default_epsilon.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ApproxEq for f32

Source§

type Eps = f32

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &f32, epsilon: &f32) -> bool

Source§

impl ApproxEq for f64

Source§

type Eps = f64

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &f64, epsilon: &f64) -> bool

Source§

impl ApproxEq for i8

Source§

type Eps = i8

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &i8, epsilon: &i8) -> bool

Source§

impl ApproxEq for i16

Source§

type Eps = i16

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &i16, epsilon: &i16) -> bool

Source§

impl ApproxEq for i32

Source§

type Eps = i32

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &i32, epsilon: &i32) -> bool

Source§

impl ApproxEq for i64

Source§

type Eps = i64

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &i64, epsilon: &i64) -> bool

Source§

impl ApproxEq for u8

Source§

type Eps = u8

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &u8, epsilon: &u8) -> bool

Source§

impl ApproxEq for u16

Source§

type Eps = u16

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &u16, epsilon: &u16) -> bool

Source§

impl ApproxEq for u32

Source§

type Eps = u32

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &u32, epsilon: &u32) -> bool

Source§

impl ApproxEq for u64

Source§

type Eps = u64

Source§

fn default_epsilon() -> Self::Eps

Source§

fn approx_eq_eps(&self, b: &u64, epsilon: &u64) -> bool

Implementors§

Source§

impl<M> ApproxEq for Wrapper<M>
where M: ApproxEq,

Source§

type Eps = <M as ApproxEq>::Eps