Skip to main content

CastFromSlice

Trait CastFromSlice 

Source
pub trait CastFromSlice<From> {
    // Required method
    fn cast_from_slice(self, from: From);
}
Expand description

Perform a numeric cast on a slice of values.

This trait is intended to have the following numerical behavior:

  1. If a lossless conversion between types is available, use that.
  2. Otherwise, if the two type are floating point types, use a round-to-nearest strategy.
  3. Otherwise, try to behave like the Rust as numeric cast.

The main reason we can’t just say “behave like “as”“ is because Rust does not have a native f16 type, which this crate supports.

Required Methods§

Source

fn cast_from_slice(self, from: From)

Implementations on Foreign Types§

Source§

impl CastFromSlice<&[f32]> for &mut [f16]

Source§

fn cast_from_slice(self, from: &[f32])

Source§

impl CastFromSlice<&[f16]> for &mut [f32]

Source§

fn cast_from_slice(self, from: &[f16])

Source§

impl<const N: usize> CastFromSlice<&[f32; N]> for &mut [f16; N]

Source§

fn cast_from_slice(self, from: &[f32; N])

Source§

impl<const N: usize> CastFromSlice<&[f16; N]> for &mut [f32; N]

Source§

fn cast_from_slice(self, from: &[f16; N])

Implementors§