pub trait Bytes: Sized + Seal {
type Bytes: Bytes<Bytes = Self::Bytes>;
// Required methods
fn to_bytes(self) -> Self::Bytes;
fn from_bytes(value: Self::Bytes) -> Self;
// Provided method
fn bitcast<U: Bytes<Bytes = Self::Bytes>>(self) -> U { ... }
}Expand description
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.
Required Associated Types§
Required Methods§
Sourcefn from_bytes(value: Self::Bytes) -> Self
fn from_bytes(value: Self::Bytes) -> Self
Reinterpret a same-width vector of u8 lanes as this vector type.
Provided Methods§
Sourcefn bitcast<U: Bytes<Bytes = Self::Bytes>>(self) -> U
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:
fn i8s_as_f64s<S: Simd>(value: S::i8s) -> S::f64s {
value.bitcast()
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".