Skip to content

Commit 2cd3d45

Browse files
committed
Fix clippy::manual-is-multiple-of (#522)
1 parent a9730f3 commit 2cd3d45

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/flatbuffers/unsafe_tools.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ pub fn fb_vector_to_slice<T>(vector: flatbuffers::Vector<'_, T>) -> &[T] {
1717
// We can't use T with the size more than MIN_ALIGNMENT.
1818
// Since the beginning of flatbuffer data is aligned to that size,
1919
// the alignment of the data must be a divisor of MIN_ALIGNMENT.
20-
assert!(MIN_ALIGNMENT % std::mem::size_of::<T>() == 0);
20+
assert!(MIN_ALIGNMENT.is_multiple_of(std::mem::size_of::<T>()));
2121
}
2222
const { static_assert_alignment::<T>() };
2323

24-
assert!(bytes.len() % std::mem::size_of::<T>() == 0);
25-
assert!(bytes.as_ptr() as usize % std::mem::align_of::<T>() == 0);
24+
assert!(bytes.len().is_multiple_of(std::mem::size_of::<T>()));
25+
assert!((bytes.as_ptr() as usize).is_multiple_of(std::mem::align_of::<T>()));
2626
unsafe {
2727
std::slice::from_raw_parts(
2828
bytes.as_ptr() as *const T,
@@ -85,7 +85,7 @@ impl VerifiedFlatbufferMemory {
8585
raw_data: vec,
8686
start,
8787
};
88-
assert!(memory.data().as_ptr() as usize % MIN_ALIGNMENT == 0);
88+
assert!((memory.data().as_ptr() as usize).is_multiple_of(MIN_ALIGNMENT));
8989
memory
9090
}
9191

0 commit comments

Comments
 (0)