mz_ore::cast

Trait CastLossy

Source
pub trait CastLossy<T> {
    // Required method
    fn cast_lossy(from: T) -> Self;
}
Expand description

A trait for potentially-lossy casts. Typically useful when converting from integers to floating point, and you want the nearest floating-point number to your integer when your integer is large, or vice versa.

Required Methods§

Source

fn cast_lossy(from: T) -> Self

Perform the lossy cast.

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 CastLossy<f64> for i64

Source§

impl CastLossy<f64> for u32

Source§

impl CastLossy<f64> for u64

Source§

impl CastLossy<f64> for usize

Source§

impl CastLossy<i64> for f64

Source§

impl CastLossy<isize> for f64

Source§

impl CastLossy<u64> for f64

Source§

impl CastLossy<usize> for f64

Implementors§