Skip to content

Commit a524017

Browse files
committed
style: clippy fix manual_is_multiple_of
NOTE: This method was added in a recent version of Rust (1.87.0), so changing to this code means that our minimum supported Rust version would become that! If you'd rather keep compatibility with older-than-stable versions of Rust, we should leave this unchanged!
1 parent a9771c1 commit a524017

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/spectrum/bindata/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'transient, 'lifespan: 'transient> DataArray {
113113
}
114114

115115
pub fn slice(&self, start: usize, end: usize) -> Result<DataArray, ArrayRetrievalError> {
116-
if end < start || (end - start) % self.dtype.size_of() != 0 {
116+
if end < start || !(end - start).is_multiple_of(self.dtype.size_of()) {
117117
Err(ArrayRetrievalError::DataTypeSizeMismatch)
118118
} else {
119119
let data = self.decode()?;
@@ -128,7 +128,7 @@ impl<'transient, 'lifespan: 'transient> DataArray {
128128
start: usize,
129129
end: usize,
130130
) -> Result<Cow<'_, [u8]>, ArrayRetrievalError> {
131-
if end < start || (end - start) % self.dtype.size_of() != 0 {
131+
if end < start || !(end - start).is_multiple_of(self.dtype.size_of()) {
132132
Err(ArrayRetrievalError::DataTypeSizeMismatch)
133133
} else {
134134
let data = self.decode()?;
@@ -792,7 +792,7 @@ impl<'transient, 'lifespan: 'transient> DataArray {
792792
start: usize,
793793
end: usize,
794794
) -> Result<Cow<'lifespan, [u8]>, ArrayRetrievalError> {
795-
if start > end || (end - start) % self.dtype.size_of() != 0 {
795+
if start > end || !(end - start).is_multiple_of(self.dtype.size_of()) {
796796
return Err(ArrayRetrievalError::DataTypeSizeMismatch);
797797
}
798798
match self.compression {

src/spectrum/bindata/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait ByteArrayView<'transient, 'lifespan: 'transient> {
2121
return Ok(Cow::Owned(Vec::new()));
2222
}
2323
let z = mem::size_of::<T>();
24-
if n % z != 0 {
24+
if !n.is_multiple_of(z) {
2525
return Err(ArrayRetrievalError::DataTypeSizeMismatch);
2626
}
2727
match buffer {
@@ -208,7 +208,7 @@ pub trait ByteArrayViewMut<'transient, 'lifespan: 'transient>:
208208
return Ok(&mut []);
209209
}
210210
let z = mem::size_of::<T>();
211-
if n % z != 0 {
211+
if !n.is_multiple_of(z) {
212212
return Err(ArrayRetrievalError::DataTypeSizeMismatch);
213213
}
214214
let m = n / z;

0 commit comments

Comments
 (0)