half::vec

Trait HalfBitsVecExt

Source
pub trait HalfBitsVecExt: SealedHalfBitsVec {
    // Required method
    fn reinterpret_into<H>(self) -> Vec<H>
       where H: SealedHalf;
}
Expand description

Extensions to Vec<u16> to support reinterpret operations.

This trait is sealed and cannot be implemented outside of this crate.

Required Methods§

Source

fn reinterpret_into<H>(self) -> Vec<H>
where H: SealedHalf,

Reinterprets a vector of u16 bits as a vector of [f16] or bf16 numbers.

H is the type to cast to, and must be either the [f16] or bf16 type.

This is a zero-copy operation. The reinterpreted vector has the same memory location as self.

§Examples
let int_buffer = vec![f16::from_f32(1.).to_bits(), f16::from_f32(2.).to_bits(), f16::from_f32(3.).to_bits()];
let float_buffer = int_buffer.reinterpret_into::<f16>();

assert_eq!(float_buffer, [f16::from_f32(1.), f16::from_f32(2.), f16::from_f32(3.)]);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl HalfBitsVecExt for Vec<u16>

Source§

fn reinterpret_into<H>(self) -> Vec<H>
where H: SealedHalf,

Implementors§