Skip to content

Commit e0623ee

Browse files
authored
fix clippy warnings for manual implementations of is_multiple_of() (#1573)
cargo clippy warns on the common pattern `a % b == 0`, which returns true if `a` is a multiple of `b`. Rust unsigned integers have an `is_multiple_of` method, which makes the intent slightly clearer.
1 parent 76adc78 commit e0623ee

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/base/vec_storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl<T, R: Dim> Extend<T> for VecStorage<T, R, Dyn> {
473473
self.data.extend(iter);
474474
self.ncols = Dyn(self.data.len() / self.nrows.value());
475475
assert!(
476-
self.data.len() % self.nrows.value() == 0,
476+
self.data.len().is_multiple_of(self.nrows.value()),
477477
"The number of elements produced by the given iterator was not a multiple of the number of rows."
478478
);
479479
}

src/linalg/permutation_sequence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ where
156156
#[inline]
157157
#[must_use]
158158
pub fn determinant<T: One + ClosedNeg>(&self) -> T {
159-
if self.len % 2 == 0 {
159+
if self.len.is_multiple_of(2) {
160160
T::one()
161161
} else {
162162
-T::one()

src/linalg/pow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
let mut x = self.clone_owned();
2727
let mut workspace = self.clone_owned();
2828

29-
if exp % 2 == 0 {
29+
if exp.is_multiple_of(2) {
3030
self.fill_with_identity();
3131
} else {
3232
// Avoid an useless multiplication by the identity

0 commit comments

Comments
 (0)