Skip to main content

IsClose

Trait IsClose 

Source
pub trait IsClose<Rhs = Self> {
    type Tolerance;

    const ZERO_TOL: Self::Tolerance;
    const ABS_TOL: Self::Tolerance;
    const REL_TOL: Self::Tolerance;

    // Required method
    fn is_close_tol(
        &self,
        rhs: &Rhs,
        rel_tol: &Self::Tolerance,
        abs_tol: &Self::Tolerance,
    ) -> bool;

    // Provided methods
    fn is_close(&self, rhs: &Rhs) -> bool { ... }
    fn is_close_rel_tol(&self, rhs: &Rhs, rel_tol: &Self::Tolerance) -> bool { ... }
    fn is_close_abs_tol(&self, rhs: &Rhs, abs_tol: &Self::Tolerance) -> bool { ... }
}
Expand description

Trait used for testing if floating point values are approximately equal

Required Associated Constants§

Source

const ZERO_TOL: Self::Tolerance

Zero tolerance value

Source

const ABS_TOL: Self::Tolerance

The default absolute tolerance value

Source

const REL_TOL: Self::Tolerance

The default relative tolerance value

Required Associated Types§

Source

type Tolerance

The type used for tolerance comparisons

Required Methods§

Source

fn is_close_tol( &self, rhs: &Rhs, rel_tol: &Self::Tolerance, abs_tol: &Self::Tolerance, ) -> bool

Check if two values are approximately equal using the given relative and absolute tolerances.

This is the only function that must be reimplemented to implement the IsClose trait for foreign types.

Provided Methods§

Source

fn is_close(&self, rhs: &Rhs) -> bool

Check if two values are approximately equal. This is equivalent to calling IsClose::is_close_tol with IsClose::REL_TOL and IsClose::ABS_TOL as the respective tolerance arguments.

Note: When implementing IsClose for foreign types the default implementation of IsClose::is_close should almost never be overridden. Instead, you should implement IsClose::is_close_tol which this function delegates to.

Source

fn is_close_rel_tol(&self, rhs: &Rhs, rel_tol: &Self::Tolerance) -> bool

Check if two values are approximately equal using the given relative tolerance. This is equivalent to calling IsClose::is_close_tol with an absolute tolerance of 0.0.

Note: When implementing IsClose for foreign types the default implementation of IsClose::is_close_rel_tol should almost never be overridden. Instead, you should implement IsClose::is_close_tol which this function delegates to.

Source

fn is_close_abs_tol(&self, rhs: &Rhs, abs_tol: &Self::Tolerance) -> bool

Check if two values are approximately equal using the given absolute tolerance. This is equivalent to calling IsClose::is_close_tol with an relative tolerance of 0.0.

Note: When implementing IsClose for foreign types the default implementation of IsClose::is_close_abs_tol should almost never be overridden. Instead, you should implement IsClose::is_close_tol which this function delegates to.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IsClose for bf16

Source§

const ZERO_TOL: Self = Self::ZERO

Source§

const ABS_TOL: Self

Source§

const REL_TOL: Self

Source§

type Tolerance = bf16

Source§

fn is_close_tol(&self, other: &Self, rel_tol: &Self, abs_tol: &Self) -> bool

Source§

impl IsClose for f16

Source§

const ZERO_TOL: Self = Self::ZERO

Source§

const ABS_TOL: Self

Source§

const REL_TOL: Self

Source§

type Tolerance = f16

Source§

fn is_close_tol(&self, other: &Self, rel_tol: &Self, abs_tol: &Self) -> bool

Source§

impl IsClose for f32

Source§

const ZERO_TOL: Self = 0.0

Source§

const ABS_TOL: Self = 1e-6

Source§

const REL_TOL: Self = 1e-6

Source§

type Tolerance = f32

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &Self, abs_tol: &Self) -> bool

Source§

impl IsClose for f64

Source§

const ZERO_TOL: Self = 0.0

Source§

const ABS_TOL: Self = 1e-9

Source§

const REL_TOL: Self = 1e-9

Source§

type Tolerance = f64

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &Self, abs_tol: &Self) -> bool

Source§

impl<T, U1, U2> IsClose for RigidTransform3D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Rotation2D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Rotation3D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Scale<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Transform2D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Transform3D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Translation2D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U1, U2> IsClose for Translation3D<T, U1, U2>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Box2D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Box3D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for HomogeneousVector<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Length<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Point2D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Point3D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Rect<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for SideOffsets2D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Size2D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Size3D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Vector2D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T, U> IsClose for Vector3D<T, U>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<T> IsClose for Angle<T>
where T: IsClose<Tolerance = T>,

Source§

const ZERO_TOL: T = <T as IsClose>::ZERO_TOL

Source§

const ABS_TOL: T = <T as IsClose>::ABS_TOL

Source§

const REL_TOL: T = <T as IsClose>::REL_TOL

Source§

type Tolerance = T

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &T, abs_tol: &T) -> bool

Source§

impl<Typ, Tol> IsClose for &Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &Tol, abs_tol: &Tol) -> bool

Source§

impl<Typ, Tol> IsClose for &mut Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

fn is_close_tol(&self, rhs: &Self, rel_tol: &Tol, abs_tol: &Tol) -> bool

Source§

impl<Typ, Tol> IsClose<&Typ> for &mut Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

fn is_close_tol(&self, rhs: &&Typ, rel_tol: &Tol, abs_tol: &Tol) -> bool

Source§

impl<Typ, Tol> IsClose<&mut Typ> for &Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

fn is_close_tol(&self, rhs: &&mut Typ, rel_tol: &Tol, abs_tol: &Tol) -> bool

Source§

impl<Typ, Tol> IsClose<Typ> for &Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

fn is_close_tol(&self, rhs: &Typ, rel_tol: &Tol, abs_tol: &Tol) -> bool

Source§

impl<Typ, Tol> IsClose<Typ> for &mut Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

fn is_close_tol(&self, rhs: &Typ, rel_tol: &Tol, abs_tol: &Tol) -> bool

Implementors§

Source§

impl<Typ, Tol> IsClose<&Typ> for Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol

Source§

impl<Typ, Tol> IsClose<&mut Typ> for Typ
where Typ: IsClose<Tolerance = Tol>,

Source§

const ZERO_TOL: Tol = <Typ as IsClose>::ZERO_TOL

Source§

const ABS_TOL: Tol = <Typ as IsClose>::ABS_TOL

Source§

const REL_TOL: Tol = <Typ as IsClose>::REL_TOL

Source§

type Tolerance = Tol