Trait FloatChecker

Source
pub trait FloatChecker<F> {
    // Required methods
    fn check(value: F) -> bool;
    fn assert(value: F);
}
Expand description

Trait for checking whether a floating point number is valid.

The implementation defines its own criteria for what constitutes a valid value.

Required Methods§

Source

fn check(value: F) -> bool

Returns true if (and only if) the given floating point number is valid according to this checker’s criteria.

The only hard requirement is that NaN must be considered invalid for all implementations of FloatChecker.

Source

fn assert(value: F)

A function that may panic if the floating point number is invalid.

Should either call assert!(check(value), ...) or debug_assert!(check(value), ...).

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.

Implementors§