Skip to content

Commit 0f795e2

Browse files
aganders3jturner314
authored andcommitted
fix(clippy): change abs() as usize to unsigned_abs()
1 parent d6b2bdc commit 0f795e2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/dimension/dimension_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ pub trait Dimension:
293293
let mut cstride = 1;
294294
for &i in order.slice() {
295295
// a dimension of length 1 can have unequal strides
296-
if dim_slice[i] != 1 && (strides[i] as isize).abs() as usize != cstride {
296+
if dim_slice[i] != 1 && (strides[i] as isize).unsigned_abs() != cstride {
297297
return false;
298298
}
299299
cstride *= dim_slice[i];

src/dimension/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ where
185185
.try_fold(0usize, |acc, (&d, &s)| {
186186
let s = s as isize;
187187
// Calculate maximum possible absolute movement along this axis.
188-
let off = d.saturating_sub(1).checked_mul(s.abs() as usize)?;
188+
let off = d.saturating_sub(1).checked_mul(s.unsigned_abs())?;
189189
acc.checked_add(off)
190190
})
191191
.ok_or_else(|| from_kind(ErrorKind::Overflow))?;
@@ -457,7 +457,7 @@ pub fn do_slice(dim: &mut usize, stride: &mut usize, slice: Slice) -> isize {
457457
};
458458

459459
// Update dimension.
460-
let abs_step = step.abs() as usize;
460+
let abs_step = step.unsigned_abs();
461461
*dim = if abs_step == 1 {
462462
m
463463
} else {
@@ -651,7 +651,7 @@ pub fn slices_intersect<D: Dimension>(
651651
Some(m) => m,
652652
None => return false,
653653
};
654-
if ind < min || ind > max || (ind - min) % step.abs() as usize != 0 {
654+
if ind < min || ind > max || (ind - min) % step.unsigned_abs() != 0 {
655655
return false;
656656
}
657657
}

0 commit comments

Comments
 (0)