Skip to main content

Packed4Slice

Struct Packed4Slice 

Source
pub struct Packed4Slice<'a, T>
where T: Packable4,
{ /* private fields */ }
Expand description

A read-only view over a packed slice of 4-bit values, stored 2 per byte.

Implementations§

Source§

impl<'a, T> Packed4Slice<'a, T>
where T: Packable4,

Source

pub fn new(data: &'a [u8], len: usize) -> Option<Packed4Slice<'a, T>>

Create a new Packed4Slice from packed bytes and logical length. Returns None if the backing buffer is too small for the requested length.

Source

pub fn len(&self) -> usize

Returns the logical length (number of elements).

Source

pub fn as_packed_slice(&self) -> &'a [u8]

Returns the underlying packed byte slice.

Source

pub fn is_empty(&self) -> bool

Returns true if empty.

Source

pub fn get(&self, index: usize) -> Option<T>

Get an element at the given logical index.

Source

pub fn sub_slice(self, range: Range<usize>) -> Option<Packed4Slice<'a, T>>

Attempts to create a zero-copy sub-slice of the packed slice.

This is only possible without allocation if the range starts at an even logical index (aligned to byte boundaries). If the range starts at an odd index, returns None.

Source§

impl<'a, T> Packed4Slice<'a, T>
where T: Packable4,

Source

pub fn unpack(&self, dest: &mut [<T as Packable4>::Unpacked])

Unpack all elements into a destination slice.

Source§

impl<'a> Packed4Slice<'a, Bf4>

Source

pub fn unpack_to_bf16(&self, dest: &mut [Bf16])

Unpack all elements into a destination slice of Bf16.

Source§

impl<'a> Packed4Slice<'a, F4>

Source

pub fn unpack_to_f32(&self, dest: &mut [F32])

Unpack all elements into a destination slice of F32.

Trait Implementations§

Source§

impl<'a, T> Clone for Packed4Slice<'a, T>
where T: Clone + Packable4,

Source§

fn clone(&self) -> Packed4Slice<'a, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T> Copy for Packed4Slice<'a, T>
where T: Copy + Packable4,

Source§

impl<'a, T> Debug for Packed4Slice<'a, T>
where T: Debug + Packable4,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, T> Eq for Packed4Slice<'a, T>
where T: Eq + Packable4,

Source§

impl<'a, T> IntoIterator for Packed4Slice<'a, T>
where T: Packable4,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = Packed4Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <Packed4Slice<'a, T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> PartialEq for Packed4Slice<'a, T>
where T: PartialEq + Packable4,

Source§

fn eq(&self, other: &Packed4Slice<'a, T>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a, T> StructuralPartialEq for Packed4Slice<'a, T>
where T: PartialEq + Packable4,

Auto Trait Implementations§

§

impl<'a, T> Freeze for Packed4Slice<'a, T>

§

impl<'a, T> RefUnwindSafe for Packed4Slice<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Packed4Slice<'a, T>
where T: Send,

§

impl<'a, T> Sync for Packed4Slice<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Packed4Slice<'a, T>
where T: Unpin,

§

impl<'a, T> UnsafeUnpin for Packed4Slice<'a, T>

§

impl<'a, T> UnwindSafe for Packed4Slice<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CastTo for T
where T: Copy,

Source§

fn cast_to<U>(self) -> U
where U: CastFrom<Self>,

Cast self to type U.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.