Trait SaturateCast

Source
pub trait SaturateCast<T>: Sized {
    // Required method
    fn saturate_from(n: T) -> Self;
}
Expand description

Custom float to integer conversion routines.

Required Methods§

Source

fn saturate_from(n: T) -> Self

Return the closest integer for the given float.

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 SaturateCast<f32> for i32

Source§

fn saturate_from(x: f32) -> Self

Return the closest integer for the given float.

Returns MAX_I32_FITS_IN_F32 for NaN.

Source§

impl SaturateCast<f64> for i32

Source§

fn saturate_from(x: f64) -> Self

Return the closest integer for the given double.

Returns i32::MAX for NaN.

Implementors§