Trait HalfBitsSliceExt
pub trait HalfBitsSliceExt: SealedHalfBitsSlice
Extensions to [u16] slices to support reinterpret operations.
This trait is sealed and cannot be implemented outside of this crate.
Required Methods
fn reinterpret_cast<H>(&self) -> &[H] where H: SealedHalf,Reinterprets a slice of
u16bits as a slice of [struct@f16] or [struct@bf16] numbers.His the type to cast to, and must be either the [struct@f16] or [struct@bf16] type.This is a zero-copy operation. The reinterpreted slice has the same lifetime and memory location as
self.Examples
# use *; let int_buffer = ; let float_buffer: & = int_buffer.reinterpret_cast; assert_eq!; // You may have to specify the cast type directly if the compiler can't infer the type. // The following is also valid in Rust. let typed_buffer = int_buffer.;fn reinterpret_cast_mut<H>(&mut self) -> &mut [H] where H: SealedHalf,Reinterprets a mutable slice of
u16bits as a mutable slice of [struct@f16] or [struct@bf16] numbers.His the type to cast to, and must be either the [struct@f16] or [struct@bf16] type.This is a zero-copy operation. The transmuted slice has the same lifetime as the original, which prevents mutating
selfas long as the returned&mut [f16]is borrowed.Examples
# use *; let mut int_buffer = ; // Note that we need to drop float_buffer before using int_buffer again or we will get a borrow error. assert_eq!; // You may have to specify the cast type directly if the compiler can't infer the type. // The following is also valid in Rust. let typed_buffer = int_buffer.;
Implementors
impl HalfBitsSliceExt for [u16]