diff --git a/src/lib.rs b/src/lib.rs index 11ff6387d8..7e4bffc2bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -172,6 +172,7 @@ clippy::correctness, clippy::dbg_macro, clippy::decimal_literal_representation, + clippy::expect_used, clippy::get_unwrap, clippy::indexing_slicing, clippy::missing_inline_in_public_items, @@ -1415,10 +1416,7 @@ pub unsafe trait AsBytes { #[inline] fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()> { let start = bytes.len().checked_sub(mem::size_of_val(self))?; - bytes - .get_mut(start..) - .expect("`start` should be in-bounds of `bytes`") - .copy_from_slice(self.as_bytes()); + bytes.get_mut(start..)?.copy_from_slice(self.as_bytes()); Some(()) } } @@ -2193,6 +2191,7 @@ where /// `new_slice` panics if `T` is a zero-sized type. #[inline] pub fn new_slice(bytes: B) -> Option> { + #[allow(clippy::expect_used)] let remainder = bytes .len() .checked_rem(mem::size_of::())