Struct easy_ml::matrices::views::MatrixPart
source · pub struct MatrixPart<'source, T> { /* private fields */ }
Expand description
A mutably borrowed part of a matrix.
Rust’s borrow checker does not not permit overlapping exclusive references, so you cannot simply construct multiple views into a Matrix by creating each one sequentially as you can for immutable/shared references to a Matrix.
use easy_ml::matrices::Matrix;
use easy_ml::matrices::views::MatrixRange;
let matrix = Matrix::row(vec![1, 2, 3]);
let one = MatrixRange::from(&matrix, 0..1, 0..1);
let two = MatrixRange::from(&matrix, 0..1, 1..2);
let three = MatrixRange::from(&matrix, 0..1, 2..3);
let four = MatrixRange::from(&matrix, 0..1, 0..3);
MatrixPart instead holds only a mutable reference to a slice into a Matrix’s buffer. It does not borrow the entire Matrix, and thus is used as the container for Matrix APIs which partition a Matrix into multiple non overlapping parts. The Matrix can then be independently mutated by each of the MatrixParts.
Trait Implementations§
source§impl<'source, T: Debug> Debug for MatrixPart<'source, T>
impl<'source, T: Debug> Debug for MatrixPart<'source, T>
source§impl<'a, T> MatrixMut<T> for MatrixPart<'a, T>
impl<'a, T> MatrixMut<T> for MatrixPart<'a, T>
A MatrixPart implements MatrixMut.
source§fn try_get_reference_mut(&mut self, row: Row, column: Column) -> Option<&mut T>
fn try_get_reference_mut(&mut self, row: Row, column: Column) -> Option<&mut T>
Gets a mutable reference to the value at the index, if the index is in range. Otherwise
returns None.
source§unsafe fn get_reference_unchecked_mut(
&mut self,
row: Row,
column: Column,
) -> &mut T
unsafe fn get_reference_unchecked_mut( &mut self, row: Row, column: Column, ) -> &mut T
Gets a mutable reference to the value at the index without doing any bounds checking.
For a safe alternative see try_get_reference_mut. Read more
source§impl<'a, T> MatrixRef<T> for MatrixPart<'a, T>
impl<'a, T> MatrixRef<T> for MatrixPart<'a, T>
A MatrixPart implements MatrixRef.
source§fn try_get_reference(&self, row: Row, column: Column) -> Option<&T>
fn try_get_reference(&self, row: Row, column: Column) -> Option<&T>
Gets a reference to the value at the index if the index is in range. Otherwise returns None.
source§fn view_rows(&self) -> Row
fn view_rows(&self) -> Row
The number of rows that this reference can view. This may be less than the actual number of
rows stored in the matrix.
source§fn view_columns(&self) -> Column
fn view_columns(&self) -> Column
The number of columns that this reference can view. This may be less than the actual number
of columns stored in the matrix.
source§unsafe fn get_reference_unchecked(&self, row: Row, column: Column) -> &T
unsafe fn get_reference_unchecked(&self, row: Row, column: Column) -> &T
Gets a reference to the value at the index without doing any bounds checking. For a safe
alternative see try_get_reference. Read more
source§fn data_layout(&self) -> DataLayout
fn data_layout(&self) -> DataLayout
A hint for the data layout this MatrixView uses to store its data. Read more
impl<'a, T> NoInteriorMutability for MatrixPart<'a, T>
A MatrixPart implements NoInteriorMutability.
Auto Trait Implementations§
impl<'source, T> Freeze for MatrixPart<'source, T>
impl<'source, T> RefUnwindSafe for MatrixPart<'source, T>where
T: RefUnwindSafe,
impl<'source, T> Send for MatrixPart<'source, T>where
T: Send,
impl<'source, T> Sync for MatrixPart<'source, T>where
T: Sync,
impl<'source, T> Unpin for MatrixPart<'source, T>
impl<'source, T> !UnwindSafe for MatrixPart<'source, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more