pub trait FloatArgument: Sealed + Sized {
// Required method
fn require_finite(self, path: &str) -> ArgumentResult<Self>;
}Expand description
Validates properties specific to floating-point arguments.
This trait is implemented only for f32 and f64. Successful validation
returns the original value with its exact bit pattern unchanged.
The trait is sealed: downstream crates can use its methods but cannot add implementations for other types.
use qubit_argument::{ArgumentResult, FloatArgument};
struct CustomFloat;
impl FloatArgument for CustomFloat {
fn require_finite(self, _path: &str) -> ArgumentResult<Self> {
Ok(self)
}
}Required Methods§
Sourcefn require_finite(self, path: &str) -> ArgumentResult<Self>
fn require_finite(self, path: &str) -> ArgumentResult<Self>
Requires this floating-point value to be finite.
Success returns the original value. NaN returns
ArgumentErrorKind::NotANumber; positive or negative infinity returns
ArgumentErrorKind::NotFinite with the exact floating-point value at
path.
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 FloatArgument for f32
impl FloatArgument for f32
Source§fn require_finite(self, path: &str) -> ArgumentResult<Self>
fn require_finite(self, path: &str) -> ArgumentResult<Self>
Requires a finite value and preserves its exact bit pattern.
Source§impl FloatArgument for f64
impl FloatArgument for f64
Source§fn require_finite(self, path: &str) -> ArgumentResult<Self>
fn require_finite(self, path: &str) -> ArgumentResult<Self>
Requires a finite value and preserves its exact bit pattern.