Skip to content

Commit 3ce3059

Browse files
committed
FIX: Add debug assertions for the axis in RemoveAxis
See previous commit, since the trait is not intended to be user facing, use debug assertions.
1 parent fa71ec5 commit 3ce3059

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/dimension/remove_axis.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ pub trait RemoveAxis : Dimension {
1919

2020
impl RemoveAxis for Dim<[Ix; 1]> {
2121
#[inline]
22-
fn remove_axis(&self, _: Axis) -> Ix0 { Ix0() }
22+
fn remove_axis(&self, axis: Axis) -> Ix0 {
23+
debug_assert!(axis.index() < self.ndim());
24+
Ix0()
25+
}
2326
}
2427

2528
impl RemoveAxis for Dim<[Ix; 2]> {
@@ -38,6 +41,7 @@ macro_rules! impl_remove_axis_array(
3841
{
3942
#[inline]
4043
fn remove_axis(&self, axis: Axis) -> Self::Smaller {
44+
debug_assert!(axis.index() < self.ndim());
4145
let mut tup = Dim([0; $n - 1]);
4246
{
4347
let mut it = tup.slice_mut().iter_mut();

0 commit comments

Comments
 (0)