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_mutreturns valid references for the given row index. This call must be memory safe fori < 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 alliin0..self.nrows(), the implementation ofSelf::get_row_mutmust be such that the result for disjointimust not interfere with one another.
Required Associated Types§
Required Methods§
Sourceunsafe fn get_row_mut<'a>(self, ptr: NonNull<u8>, i: usize) -> Self::RowMut<'a>
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
ptrmust point to a slice with a layout compatible withRepr::layout.- The entire range for this slice must be within a single allocation.
imust be less thanself.nrows().- The memory referenced by the returned
ReprMut::RowMutmust not be accessed through any other reference for the duration of lifetime'a. - The lifetime for the returned
ReprMut::RowMutis 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.