Skip to main content

ReprMut

Trait ReprMut 

Source
pub unsafe trait ReprMut: Repr {
    type RowMut<'a>
       where Self: 'a;

    // Required method
    unsafe fn get_row_mut<'a>(
        self,
        ptr: NonNull<u8>,
        i: usize,
    ) -> Self::RowMut<'a>;
}
Expand description

Extension of Repr that supports mutable row access.

§Associated Types

  • RowMut<'a>: The mutable row type (e.g., &mut [f32]).

§Safety

Implementors must ensure:

  • get_row_mut returns valid references for the given row index. This call must be memory safe for i < self.nrows(), provided the caller upholds the contract for the raw pointer.

    Additionally, since the implementation of the [RowsMut] iterator can give out rows for all i in 0..self.nrows(), the implementation of Self::get_row_mut must be such that the result for disjoint i must not interfere with one another.

Required Associated Types§

Source

type RowMut<'a> where Self: 'a

Mutable row reference type.

Required Methods§

Source

unsafe fn get_row_mut<'a>(self, ptr: NonNull<u8>, i: usize) -> Self::RowMut<'a>

Returns a mutable reference to the i-th row.

§Safety
  • ptr must point to a slice with a layout compatible with Repr::layout.
  • The entire range for this slice must be within a single allocation.
  • i must be less than self.nrows().
  • The memory referenced by the returned ReprMut::RowMut must not be accessed through any other reference for the duration of lifetime 'a.
  • The lifetime for the returned ReprMut::RowMut is inferred from its usage. Correct usage must properly tie the lifetime to a source.

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<T: Copy> ReprMut for Standard<T>

Source§

type RowMut<'a> = &'a mut [T] where T: 'a

Source§

impl<const NBITS: usize> ReprMut for MinMaxMeta<NBITS>
where Unsigned: Representation<NBITS>,