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.

Object Safety§

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§