devela::_dep::bytemuck

Function try_pod_read_unaligned

pub fn try_pod_read_unaligned<T>(bytes: &[u8]) -> Result<T, PodCastError> 
where T: AnyBitPattern,
Available on crate feature dep_bytemuck only.
Expand description

Reads from the bytes as if they were a T.

Unlike from_bytes, the slice doesn’t need to respect alignment of T, only sizes must match.

§Failure

  • If the bytes length is not equal to size_of::<T>().