Trait RealValueValidator

Source
pub trait RealValueValidator: Sized {
    // Required method
    fn validate(self) -> Result<Self, RealValueErrors<Self>>;
}
Expand description

A trait for validating real values.

This trait provides a method for validating real values, ensuring that they are not infinite, NaN, or subnormal. If the value is valid, it returns Ok(self). Otherwise, it returns an appropriate error variant of RealValueErrors.

Required Methods§

Source

fn validate(self) -> Result<Self, RealValueErrors<Self>>

Validates the real value.

§Returns
  • Ok(self) if the value is valid (i.e., it is not infinite, NaN, or subnormal).
  • Err(RealValueErrors::Infinite) if the value is infinite.
  • Err(RealValueErrors::NaN) if the value is NaN.
  • Err(RealValueErrors::Subnormal) if the value is subnormal.

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 RealValueValidator for f64

Source§

fn validate(self) -> Result<Self, RealValueErrors<Self>>

Validates the f64 value.

This implementation checks the floating-point category of the value and returns an appropriate error if the value is infinite, NaN, or subnormal.

§Returns
  • Ok(self) if the value is valid (i.e., it is not infinite, NaN, or subnormal).
  • Err(RealValueErrors::Infinite) if the value is infinite.
  • Err(RealValueErrors::NaN) if the value is NaN.
  • Err(RealValueErrors::Subnormal) if the value is subnormal.

Implementors§