Closed Enselic closed 10 months ago
In the case of #![allow(clippy::unnecessary_cast)] the current code is by my estimation clearer and more symmetric than the code clippy would want, so I ended up allowing unnecessary casts.
Do you mean these changes? They seem okay to me at first glance.
diff --git a/src/read/endian_reader.rs b/src/read/endian_reader.rs
index 8852b380..ef927e52 100644
--- a/src/read/endian_reader.rs
+++ b/src/read/endian_reader.rs
@@ -393,8 +393,8 @@ where
#[inline]
fn offset_from(&self, base: &EndianReader<Endian, T>) -> usize {
- let base_ptr = base.bytes().as_ptr() as *const u8 as usize;
- let ptr = self.bytes().as_ptr() as *const u8 as usize;
+ let base_ptr = base.bytes().as_ptr() as usize;
+ let ptr = self.bytes().as_ptr() as usize;
debug_assert!(base_ptr <= ptr);
debug_assert!(ptr + self.bytes().len() <= base_ptr + base.bytes().len());
ptr - base_ptr
diff --git a/src/read/endian_slice.rs b/src/read/endian_slice.rs
index 0db28dac..b327a84f 100644
--- a/src/read/endian_slice.rs
+++ b/src/read/endian_slice.rs
@@ -68,8 +68,8 @@ where
/// of the given slice.
#[inline]
pub fn offset_from(&self, base: EndianSlice<'input, Endian>) -> usize {
- let base_ptr = base.slice.as_ptr() as *const u8 as usize;
- let ptr = self.slice.as_ptr() as *const u8 as usize;
+ let base_ptr = base.slice.as_ptr() as usize;
+ let ptr = self.slice.as_ptr() as usize;
debug_assert!(base_ptr <= ptr);
debug_assert!(ptr + self.slice.len() <= base_ptr + base.slice.len());
ptr - base_ptr
Do you mean these changes? They seem okay to me at first glance.
Ok, let's go with those then. I pushed a commit for that now.
This PR makes these commands return no warnings (except "unknown lint" from 1.60 for
clippy::bool_to_int_with_if
andclippy::derive_partial_eq_without_eq
).In the case of
#![allow(clippy::unnecessary_cast)]
the current code is by my estimation clearer and more symmetric than the code clippy would want, so I ended up allowing unnecessary casts.