pub unsafe trait MatrixIndex<T: ?Sized>: Sealed {
type Output: ?Sized;
// Required methods
fn get(self, matrix: &T) -> Option<&Self::Output>;
fn get_mut(self, matrix: &mut T) -> Option<&mut Self::Output>;
unsafe fn get_unchecked(self, matrix: *const T) -> *const Self::Output;
unsafe fn get_unchecked_mut(self, stride: *mut T) -> *mut Self::Output;
fn index(self, stride: &T) -> &Self::Output;
fn index_mut(self, stride: &mut T) -> &mut Self::Output;
}Expand description
A helper trait used for indexing operations.
This is the Matrix version of SliceIndex.
You should not use or implement this trait directly but instead use the
corresponding methods on Matrix.
§Safety
Implementations of this trait have to promise that if the argument
to get_(mut_)unchecked is a safe reference, then so is the result.
Required Associated Types§
Required Methods§
Sourcefn get(self, matrix: &T) -> Option<&Self::Output>
fn get(self, matrix: &T) -> Option<&Self::Output>
Returns a shared reference to the output at this location, if in bounds.
Sourcefn get_mut(self, matrix: &mut T) -> Option<&mut Self::Output>
fn get_mut(self, matrix: &mut T) -> Option<&mut Self::Output>
Returns a mutable reference to the output at this location, if in bounds.
Sourceunsafe fn get_unchecked(self, matrix: *const T) -> *const Self::Output
unsafe fn get_unchecked(self, matrix: *const T) -> *const Self::Output
Returns a shared reference to the output at this location, without performing any bounds checking.
§Safety
Calling this method with an out-of-bounds index or a dangling matrix
pointer is undefined behavior even if the resulting reference is not
used.
Sourceunsafe fn get_unchecked_mut(self, stride: *mut T) -> *mut Self::Output
unsafe fn get_unchecked_mut(self, stride: *mut T) -> *mut Self::Output
Returns a mutable reference to the output at this location, without performing any bounds checking.
§Safety
Calling this method with an out-of-bounds index or a dangling matrix
pointer is undefined behavior even if the resulting reference is not
used.