Trait spirv_std::arch::IndexUnchecked

source ·
pub trait IndexUnchecked<T> {
    // Required methods
    unsafe fn index_unchecked(&self, index: usize) -> &T;
    unsafe fn index_unchecked_mut(&mut self, index: usize) -> &mut T;
}
Expand description

Index into an array without bounds checking.

The main purpose of this trait is to work around the fact that the regular get_unchecked* methods do not work in in SPIR-V.

Required Methods§

source

unsafe fn index_unchecked(&self, index: usize) -> &T

Returns a reference to the element at index. The equivalent of get_unchecked.

§Safety

Behavior is undefined if the index value is greater than or equal to the length of the array.

source

unsafe fn index_unchecked_mut(&mut self, index: usize) -> &mut T

Returns a mutable reference to the element at index. The equivalent of get_unchecked_mut.

§Safety

Behavior is undefined if the index value is greater than or equal to the length of the array.

Implementations on Foreign Types§

source§

impl<T> IndexUnchecked<T> for [T]

source§

unsafe fn index_unchecked(&self, index: usize) -> &T

source§

unsafe fn index_unchecked_mut(&mut self, index: usize) -> &mut T

source§

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

source§

unsafe fn index_unchecked(&self, index: usize) -> &T

source§

unsafe fn index_unchecked_mut(&mut self, index: usize) -> &mut T

Implementors§