Trait Bytes

pub trait Bytes: Sized + Seal

Conversion of SIMD vectors to and from same-width vectors of u8 lanes.

Bytes::bitcast uses this byte representation to reinterpret any two non-mask SIMD vectors with the same total width and SIMD token. This is a bitwise reinterpretation: it does not perform numeric conversion.

Associated Types

type Bytes: Bytes<Bytes = Self::Bytes>;

The same-width SIMD vector of u8 lanes used as the byte representation.

This type is its own byte representation.

Required Methods

fn to_bytes(self) -> Self::Bytes

Reinterpret this vector as a same-width vector of u8 lanes.

fn from_bytes(value: Self::Bytes) -> Self

Reinterpret a same-width vector of u8 lanes as this vector type.

Provided Methods

fn bitcast<U: Bytes<Bytes = Self::Bytes>>(self) -> U

Bitcast directly to another SIMD vector with the same byte representation. This is effectively a safe transmute for SIMD types.

This works in code generic over a Simd implementation, including between native-width vectors with different lane types:

# use fearless_simd::prelude::*;
fn i8s_as_f64s<S: Simd>(value: S::i8s) -> S::f64s {
    value.bitcast()
}

Implementors