Skip to main content

MaybeIndexUnchecked

Trait MaybeIndexUnchecked 

Source
pub trait MaybeIndexUnchecked<T> {
    // Required methods
    fn at(&self, id: usize) -> &T;
    fn at_mut(&mut self, id: usize) -> &mut T;
    fn read(&self, id: usize) -> T;
    fn write(&mut self, id: usize, data: T);
}
Expand description

Indexing trait that optionally removes bounds checks on GPU targets.

When the unsafe_remove_boundchecks feature is enabled, methods use unchecked indexing for performance on SPIR-V and CUDA targets. Otherwise, standard bounds-checked indexing is used.

Required Methods§

Source

fn at(&self, id: usize) -> &T

Returns a reference to the element at id.

Source

fn at_mut(&mut self, id: usize) -> &mut T

Returns a mutable reference to the element at id.

Source

fn read(&self, id: usize) -> T

Copies and returns the element at id.

Source

fn write(&mut self, id: usize, data: T)

Writes data to the element at id.

Implementations on Foreign Types§

Source§

impl<T: Copy> MaybeIndexUnchecked<T> for [T]

Source§

fn at(&self, id: usize) -> &T

Source§

fn at_mut(&mut self, id: usize) -> &mut T

Source§

fn read(&self, id: usize) -> T

Source§

fn write(&mut self, id: usize, data: T)

Source§

impl<T: Copy, const N: usize> MaybeIndexUnchecked<T> for [T; N]

Source§

fn at(&self, id: usize) -> &T

Source§

fn at_mut(&mut self, id: usize) -> &mut T

Source§

fn read(&self, id: usize) -> T

Source§

fn write(&mut self, id: usize, data: T)

Implementors§