diff --git a/src/arraytraits.rs b/src/arraytraits.rs index 6a4fd1137..d845c3075 100644 --- a/src/arraytraits.rs +++ b/src/arraytraits.rs @@ -336,6 +336,11 @@ impl<'a, A, const N: usize> From<&'a [[A; N]]> for ArrayView<'a, A, Ix2> { if size_of::() == 0 { dimension::size_of_shape_checked(&dim) .expect("Product of non-zero axis lengths must not overflow isize."); + } else if N == 0 { + assert!( + xs.len() <= isize::MAX as usize, + "Product of non-zero axis lengths must not overflow isize.", + ); } // `cols * rows` is guaranteed to fit in `isize` because we checked that it fits in @@ -392,6 +397,11 @@ impl<'a, A, const N: usize> From<&'a mut [[A; N]]> for ArrayViewMut<'a, A, Ix2> if size_of::() == 0 { dimension::size_of_shape_checked(&dim) .expect("Product of non-zero axis lengths must not overflow isize."); + } else if N == 0 { + assert!( + xs.len() <= isize::MAX as usize, + "Product of non-zero axis lengths must not overflow isize.", + ); } // `cols * rows` is guaranteed to fit in `isize` because we checked that it fits in