Annotate `get_mut`/`slice`-like functions with `#[must_use]`
This commit is contained in:
parent
e1fe76235f
commit
38e9a5da33
|
@ -329,6 +329,7 @@ impl<T> CscMatrix<T> {
|
|||
|
||||
/// Mutable column access for the given column index, or `None` if out of bounds.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_col_mut(&mut self, index: usize) -> Option<CscColMut<T>> {
|
||||
self.cs.get_lane_mut(index).map(|lane| CscColMut { lane })
|
||||
}
|
||||
|
@ -691,6 +692,7 @@ impl<'a, T> CscColMut<'a, T> {
|
|||
}
|
||||
|
||||
/// Returns a mutable entry for the given global row index.
|
||||
#[must_use]
|
||||
pub fn get_entry_mut(&mut self, global_row_index: usize) -> Option<SparseEntryMut<T>> {
|
||||
self.lane.get_entry_mut(global_row_index)
|
||||
}
|
||||
|
|
|
@ -331,6 +331,7 @@ impl<T> CsrMatrix<T> {
|
|||
|
||||
/// Mutable row access for the given row index, or `None` if out of bounds.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_row_mut(&mut self, index: usize) -> Option<CsrRowMut<T>> {
|
||||
self.cs.get_lane_mut(index).map(|lane| CsrRowMut { lane })
|
||||
}
|
||||
|
@ -695,6 +696,7 @@ impl<'a, T> CsrRowMut<'a, T> {
|
|||
|
||||
/// Returns a mutable entry for the given global column index.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_entry_mut(&mut self, global_col_index: usize) -> Option<SparseEntryMut<T>> {
|
||||
self.lane.get_entry_mut(global_col_index)
|
||||
}
|
||||
|
|
|
@ -496,6 +496,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||
/// Produces a mutable view of the data at the given index, or
|
||||
/// `None` if the index is out of bounds.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_mut<'a, I>(&'a mut self, index: I) -> Option<I::OutputMut>
|
||||
where
|
||||
S: StorageMut<T, R, C>,
|
||||
|
@ -540,6 +541,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||
/// Returns a mutable view of the data at the given index, without doing
|
||||
/// any bounds checking.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub unsafe fn get_unchecked_mut<'a, I>(&'a mut self, index: I) -> I::OutputMut
|
||||
where
|
||||
S: StorageMut<T, R, C>,
|
||||
|
|
|
@ -1266,6 +1266,7 @@ impl<T: Scalar, D: Dim, S: Storage<T, D>> Vector<T, D, S> {
|
|||
impl<T: Scalar, D: Dim, S: StorageMut<T, D>> Vector<T, D, S> {
|
||||
/// Gets a mutable reference to the i-th element of this column vector without bound checking.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub unsafe fn vget_unchecked_mut(&mut self, i: usize) -> &mut T {
|
||||
debug_assert!(i < self.nrows(), "Vector index out of bounds.");
|
||||
let i = i * self.strides().0;
|
||||
|
@ -1285,6 +1286,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: ContiguousStorage<T, R, C>> Matrix<T, R, C, S
|
|||
impl<T: Scalar, R: Dim, C: Dim, S: ContiguousStorageMut<T, R, C>> Matrix<T, R, C, S> {
|
||||
/// Extracts a mutable slice containing the entire matrix entries ordered column-by-columns.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn as_mut_slice(&mut self) -> &mut [T] {
|
||||
self.data.as_mut_slice()
|
||||
}
|
||||
|
|
|
@ -277,6 +277,7 @@ impl<T: Scalar, const D: usize> Point<T, D> {
|
|||
|
||||
/// Gets a mutable reference to i-th element of this point without bound-checking.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub unsafe fn get_unchecked_mut(&mut self, i: usize) -> &mut T {
|
||||
self.coords.vget_unchecked_mut(i)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue