Skip to main content

FloatOption

Trait FloatOption 

Source
pub trait FloatOption<F: Float>:
    Clone
    + Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn to_option(&self) -> Option<F>;
}
Expand description

A trait to abstract over float types (f32, f64) and their Option variants.

It provides a unified way to convert these types into an Option<F> where F is a type that implements the Float trait.

Required Methods§

Source

fn to_option(&self) -> Option<F>

Converts the implementing type into an Option<F>.

  • For a float type F, NaN is treated as a missing value (None).
  • For Option<F>, this handles Some(NaN) by returning None, and passes through Some(value) and None.

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<F> FloatOption<F> for Option<F>
where F: Float + Debug + Send + Sync + 'static,

Source§

fn to_option(&self) -> Option<F>

Implementors§

Source§

impl<F> FloatOption<F> for F
where F: Float + Debug + Send + Sync + 'static,