Trait vectrix::MatrixIndex

source ·
pub unsafe trait MatrixIndex<T: ?Sized>: Sealed {
    type Output: ?Sized;

    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

The output type returned by methods.

Required Methods

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

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

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.

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.

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

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

Implementations on Foreign Types

Implementors