nalgebra::base::storage

Trait RawStorageMut

Source
pub unsafe trait RawStorageMut<T, R: Dim, C: Dim = U1>: RawStorage<T, R, C> {
    // Required methods
    fn ptr_mut(&mut self) -> *mut T;
    unsafe fn as_mut_slice_unchecked(&mut self) -> &mut [T];

    // Provided methods
    fn get_address_unchecked_linear_mut(&mut self, i: usize) -> *mut T { ... }
    fn get_address_unchecked_mut(&mut self, irow: usize, icol: usize) -> *mut T { ... }
    unsafe fn get_unchecked_linear_mut(&mut self, i: usize) -> &mut T { ... }
    unsafe fn get_unchecked_mut(&mut self, irow: usize, icol: usize) -> &mut T { ... }
    unsafe fn swap_unchecked_linear(&mut self, i1: usize, i2: usize) { ... }
    unsafe fn swap_unchecked(
        &mut self,
        row_col1: (usize, usize),
        row_col2: (usize, usize),
    ) { ... }
}
Expand description

Trait implemented by matrix data storage that can provide a mutable access to its elements.

§Safety

In generic code, it is recommended use the StorageMut trait bound instead. The RawStorageMut trait bound is generally used by code that needs to work with storages that contains MaybeUninit<T> elements.

Note that a mutable access does not mean that the matrix owns its data. For example, a mutable matrix view can provide mutable access to its elements even if it does not own its data (it contains only an internal reference to them).

Required Methods§

Source

fn ptr_mut(&mut self) -> *mut T

The matrix mutable data pointer.

Source

unsafe fn as_mut_slice_unchecked(&mut self) -> &mut [T]

Retrieves the mutable data buffer as a contiguous slice.

Matrix components may not be contiguous, depending on its strides.

§Safety

The matrix components may not be stored in a contiguous way, depending on the strides. This method is unsafe because this can yield to invalid aliasing when called on some pairs of matrix slices originating from the same matrix with strides.

Provided Methods§

Source

fn get_address_unchecked_linear_mut(&mut self, i: usize) -> *mut T

Gets the mutable address of the i-th matrix component without performing bound-checking.

§Safety

If the index is out of bounds, dereferencing the result will cause undefined behavior.

Source

fn get_address_unchecked_mut(&mut self, irow: usize, icol: usize) -> *mut T

Gets the mutable address of the i-th matrix component without performing bound-checking.

§Safety

If the index is out of bounds, dereferencing the result will cause undefined behavior.

Source

unsafe fn get_unchecked_linear_mut(&mut self, i: usize) -> &mut T

Retrieves a mutable reference to the i-th element without bound-checking.

§Safety

If the index is out of bounds, the method will cause undefined behavior.

Source

unsafe fn get_unchecked_mut(&mut self, irow: usize, icol: usize) -> &mut T

Retrieves a mutable reference to the element at (irow, icol) without bound-checking.

§Safety

If the index is out of bounds, the method will cause undefined behavior.

Source

unsafe fn swap_unchecked_linear(&mut self, i1: usize, i2: usize)

Swaps two elements using their linear index without bound-checking.

§Safety

If the indices are out of bounds, the method will cause undefined behavior.

§Validity

The default implementation of this trait function is only guaranteed to be sound if invocations of self.ptr_mut() and self.get_address_unchecked_linear_mut() result in stable references. If any of the data pointed to by these trait methods moves as a consequence of invoking either of these methods then this default trait implementation may be invalid or unsound and should be overridden.

Source

unsafe fn swap_unchecked( &mut self, row_col1: (usize, usize), row_col2: (usize, usize), )

Swaps two elements without bound-checking.

§Safety

If the indices are out of bounds, the method will cause undefined behavior.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> RawStorageMut<T, R, C> for ViewStorageMut<'a, T, R, C, RStride, CStride>

Source§

impl<T, const R: usize, const C: usize> RawStorageMut<T, Const<R>, Const<C>> for ArrayStorage<T, R, C>