Skip to content

Commit faf02c5

Browse files
committed
integrate overlap check into can_index_slice
1 parent 7c0f216 commit faf02c5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/dimension.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,18 @@ pub fn can_index_slice<A, D: Dimension>(data: &[A],
7878
if let Some(offset) = dim.stride_offset_checked(strides, &last_index) {
7979
// offset is guaranteed to be positive so no issue converting
8080
// to usize here
81-
if (offset as usize) < data.len() {
82-
return true;
81+
if (offset as usize) >= data.len() {
82+
return false;
83+
}
84+
if dim_stride_overlap(dim, strides) {
85+
return false;
8386
}
8487
}
88+
true
89+
}
90+
else {
91+
false
8592
}
86-
false
8793
}
8894

8995
/// Trait for the shape and index types of arrays.

0 commit comments

Comments
 (0)