Struct spirv_std::RuntimeArray
source · #[repr(C)]pub struct RuntimeArray<T> { /* private fields */ }
Expand description
Dynamically-sized arrays in Rust carry around their length as the second half of a tuple. Unfortunately, sometimes SPIR-V provides an unsized array with no way of obtaining its length. Hence, this type represents something very similar to a slice, but with no way of knowing its length.
Implementations§
source§impl<T> RuntimeArray<T>
impl<T> RuntimeArray<T>
sourcepub unsafe fn index(&self, index: usize) -> &T
pub unsafe fn index(&self, index: usize) -> &T
Index the array. Unfortunately, because the length of the runtime array cannot be known, this function will happily index outside of the bounds of the array, and so is unsafe.
§Safety
Bounds checking is not performed, and indexing outside the bounds of the array can happen, and lead to UB.
sourcepub unsafe fn index_mut(&mut self, index: usize) -> &mut T
pub unsafe fn index_mut(&mut self, index: usize) -> &mut T
Index the array, returning a mutable reference to an element. Unfortunately, because the length of the runtime array cannot be known, this function will happily index outside of the bounds of the array, and so is unsafe.
§Safety
Bounds checking is not performed, and indexing outside the bounds of the array can happen, and lead to UB.