pub trait ComplexValueValidator: Sized {
type RealType: Sized;
// Required method
fn validate(self) -> Result<Self, ComplexValueErrors<Self::RealType, Self>>;
}
Expand description
A trait for validating complex values.
This trait provides a method for validating complex values, ensuring that their
real and imaginary parts are not infinite, NaN, or subnormal. If the value is valid,
it returns Ok(self)
. Otherwise, it returns an appropriate error variant of ComplexValueErrors
.
Required Associated Types§
Required Methods§
Sourcefn validate(self) -> Result<Self, ComplexValueErrors<Self::RealType, Self>>
fn validate(self) -> Result<Self, ComplexValueErrors<Self::RealType, Self>>
Validates the complex value.
§Returns
Ok(self)
if the value is valid (i.e., both the real and imaginary parts are not infinite, NaN, or subnormal).Err(ComplexValueErrors::InvalidRealPart)
if the real part is invalid.Err(ComplexValueErrors::InvalidImaginaryPart)
if the imaginary part is invalid.
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 ComplexValueValidator for Complex<f64>
impl ComplexValueValidator for Complex<f64>
Source§fn validate(self) -> Result<Self, ComplexValueErrors<Self::RealType, Self>>
fn validate(self) -> Result<Self, ComplexValueErrors<Self::RealType, Self>>
Validates the Complex<f64>
value.
This implementation checks the floating-point category of the real and imaginary parts of the complex value and returns an appropriate error if either part is infinite, NaN, or subnormal.
§Returns
Ok(self)
if the value is valid (i.e., both the real and imaginary parts are not infinite, NaN, or subnormal).Err(ComplexValueErrors::InvalidRealPart)
if the real part is invalid.Err(ComplexValueErrors::InvalidImaginaryPart)
if the imaginary part is invalid.