spirv_std::arch

Trait 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§