Reorganize matrix slice macros.
@@ -274,11 +274,6 @@ macro_rules! matrix_slice_impl(
$generic_slice_with_steps: ident,
$rows_range_pair: ident,
$columns_range_pair: ident) => {
- /// A matrix slice.
- pub type $MatrixSlice<'a, N, R, C, RStride, CStride>
- = Matrix<N, R, C, $SliceStorage<'a, N, R, C, RStride, CStride>>;
-
- impl<N: Scalar, R: Dim, C: Dim, S: $Storage<N, R, C>> Matrix<N, R, C, S> {
/*
*
* Row slicing.
@@ -631,9 +626,17 @@ macro_rules! matrix_slice_impl(
}
}
}
- }
);
+/// A matrix slice.
+pub type MatrixSlice<'a, N, R, C, RStride, CStride> =
+ Matrix<N, R, C, SliceStorage<'a, N, R, C, RStride, CStride>>;
+/// A mutable matrix slice.
+pub type MatrixSliceMut<'a, N, R, C, RStride, CStride> =
+ Matrix<N, R, C, SliceStorageMut<'a, N, R, C, RStride, CStride>>;
+
+/// # Slicing based on index and length
+impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
matrix_slice_impl!(
self: &Self, MatrixSlice, SliceStorage, Storage.get_address_unchecked(), &self.data;
row,
@@ -660,7 +663,10 @@ matrix_slice_impl!(
generic_slice_with_steps,
rows_range_pair,
columns_range_pair);
+}
+/// # Mutable slicing based on index and length
+impl<N: Scalar, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
matrix_slice_impl!(
self: &mut Self, MatrixSliceMut, SliceStorageMut, StorageMut.get_address_unchecked_mut(), &mut self.data;
row_mut,
@@ -687,6 +693,7 @@ matrix_slice_impl!(
generic_slice_with_steps_mut,
rows_range_pair_mut,
columns_range_pair_mut);
+}
/// A range with a size that may be known at compile-time.
///
@@ -803,6 +810,7 @@ impl<D: Dim> SliceRange<D> for RangeFull {
}
}
+/// # Slicing based on ranges
impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
/// Slices a sub-matrix containing the rows indexed by the range `rows` and the columns indexed
/// by the range `cols`.
@@ -842,6 +850,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
}
}
+/// # Mutable slicing based on ranges
impl<N: Scalar, R: Dim, C: Dim, S: StorageMut<N, R, C>> Matrix<N, R, C, S> {
/// Slices a mutable sub-matrix containing the rows indexed by the range `rows` and the columns
/// indexed by the range `cols`.
