Trait packed_simd_2::Cast[][src]

pub trait Cast<T>: Sized {
    fn cast(self) -> T;
}
Expand description

Numeric cast from Self to T.

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

fn cast(self) -> T[src]

Expand description

Numeric cast from self to T.

Implementors

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 
[src]

FromCast implies Cast.

fn cast(self) -> U[src]