Trait MatrixIndex

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

Source

type Output: ?Sized

The output type returned by methods.

Required Methods§

Source

fn get(self, matrix: &T) -> Option<&Self::Output>

Returns a shared reference to the output at this location, if in bounds.

Source

fn get_mut(self, matrix: &mut T) -> Option<&mut Self::Output>

Returns a mutable reference to the output at this location, if in bounds.

Source

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.

Source

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.

Source

fn index(self, stride: &T) -> &Self::Output

Returns a shared reference to the output at this location, panicking if out of bounds.

Source

fn index_mut(self, stride: &mut T) -> &mut Self::Output

Returns a mutable reference to the output at this location, panicking if out of bounds.

Implementations on Foreign Types§

Source§

impl<T, const M: usize, const N: usize> MatrixIndex<Matrix<M, N, T>> for (usize, usize)

Source§

type Output = T

Source§

fn get(self, matrix: &Matrix<M, N, T>) -> Option<&Self::Output>

Source§

fn get_mut(self, matrix: &mut Matrix<M, N, T>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked( self, matrix: *const Matrix<M, N, T>, ) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut( self, matrix: *mut Matrix<M, N, T>, ) -> *mut Self::Output

Source§

fn index(self, matrix: &Matrix<M, N, T>) -> &Self::Output

Source§

fn index_mut(self, matrix: &mut Matrix<M, N, T>) -> &mut Self::Output

Source§

impl<T, const M: usize, const N: usize> MatrixIndex<Matrix<M, N, T>> for usize

Source§

type Output = T

Source§

fn get(self, matrix: &Matrix<M, N, T>) -> Option<&Self::Output>

Source§

fn get_mut(self, matrix: &mut Matrix<M, N, T>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked( self, matrix: *const Matrix<M, N, T>, ) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut( self, matrix: *mut Matrix<M, N, T>, ) -> *mut Self::Output

Source§

fn index(self, matrix: &Matrix<M, N, T>) -> &Self::Output

Source§

fn index_mut(self, matrix: &mut Matrix<M, N, T>) -> &mut Self::Output

Implementors§