Trait packed_simd_2::FromCast[][src]

pub trait FromCast<T>: Sized {
    fn from_cast(_: T) -> Self;
}
Expand description

Numeric cast from T to Self.

Note: This is a temporary workaround until the conversion traits specified > in RFC2484 are implemented.

Numeric cast between vectors with the same number of lanes, such that:

  • casting integer vectors whose lane types have the same size (e.g. i32xN -> u32xN) is a no-op,

  • casting from a larger integer to a smaller integer (e.g. u32xN -> u8xN) will truncate,

  • casting from a smaller integer to a larger integer (e.g. u8xN -> u32xN) will:

    • zero-extend if the source is unsigned, or
    • sign-extend if the source is signed,
  • casting from a float to an integer will round the float towards zero,

  • casting from an integer to float will produce the floating point representation of the integer, rounding to nearest, ties to even,

  • casting from an f32 to an f64 is perfect and lossless,

  • casting from an f64 to an f32 rounds to nearest, ties to even.

Required methods

Numeric cast from T to Self.

Implementors

FromCast and Cast are reflexive