mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-21 22:32:23 +00:00
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.
This commit is contained in:
parent
f14410f329
commit
911f43db98
@ -404,7 +404,7 @@ pub fn from_bytes_mut<T: NoUninit + CheckedBitPattern>(s: &mut [u8]) -> &mut T {
|
||||
/// ## Panics
|
||||
/// * This is like `try_pod_read_unaligned` but will panic on failure.
|
||||
#[inline]
|
||||
pub fn pod_read_unaligned<T: AnyBitPattern>(bytes: &[u8]) -> T {
|
||||
pub fn pod_read_unaligned<T: CheckedBitPattern>(bytes: &[u8]) -> T {
|
||||
match try_pod_read_unaligned(bytes) {
|
||||
Ok(t) => t,
|
||||
Err(e) => something_went_wrong("pod_read_unaligned", e),
|
||||
|
Loading…
Reference in New Issue
Block a user