Skip to main content

IndexedSource

Trait IndexedSource 

Source
pub trait IndexedSource {
    type Item: Copy;

    // Required methods
    fn len(&self) -> usize;
    unsafe fn get_unchecked(&self, i: usize) -> Self::Item;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A length-known source supporting unchecked indexed reads.

Implemented for &[T] (with T: Copy) and for LaneZip over two IndexedSources. The kernels in this crate require this trait instead of Iterator so that lane reads carry no inter-iteration data dependency — the autovectorizer treats each lane independently.

Required Associated Types§

Source

type Item: Copy

The per-lane item type. Must be Copy so the kernels can pass it through the closure by value without extra moves.

Required Methods§

Source

fn len(&self) -> usize

Logical lane count.

Source

unsafe fn get_unchecked(&self, i: usize) -> Self::Item

Read the lane at i without bounds checking.

§Safety

i must be strictly less than self.len().

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns true when there are no lanes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Copy> IndexedSource for &[T]

Source§

type Item = T

Source§

fn len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> T

Source§

impl<T: Copy> IndexedSource for &mut [T]

Source§

type Item = T

Source§

fn len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> T

Implementors§