From 911f43db98ff9e1d663104ff06e10722c5897720 Mon Sep 17 00:00:00 2001 From: zachs18 <8355914+zachs18@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:12:32 -0600 Subject: [PATCH] Make `checked::pod_read_unaligned` require `T: CheckedBitPattern` (#150) Currently, `checked::pod_read_unaligned` requires `T: AnyBitPattern`. (This was likely just a copy-paste error from when the function was introduced in #91.) There should be no current UB nor semver breakage, since this only relaxes the bound (any type this previously worked with was already sound and will continue to work). `checked::try_pod_read_unaligned has the correct `T: CheckedBitPattern` bound. --- src/checked.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checked.rs b/src/checked.rs index 2fea55d..d28eaa7 100644 --- a/src/checked.rs +++ b/src/checked.rs @@ -404,7 +404,7 @@ pub fn from_bytes_mut(s: &mut [u8]) -> &mut T { /// ## Panics /// * This is like `try_pod_read_unaligned` but will panic on failure. #[inline] -pub fn pod_read_unaligned(bytes: &[u8]) -> T { +pub fn pod_read_unaligned(bytes: &[u8]) -> T { match try_pod_read_unaligned(bytes) { Ok(t) => t, Err(e) => something_went_wrong("pod_read_unaligned", e),