[−][src]Function safe_transmute::guarded_transmute_pod_many_permissive
pub fn guarded_transmute_pod_many_permissive<T: PodTransmutable>(
bytes: &[u8]
) -> Result<&[T], Error>
View a byte slice as a slice of a POD type.
The resulting slice will have as many instances of a type as will fit, rounded down.
Errors
An error is raised in one of the following situations:
- The data does not have a memory alignment compatible with
T
. You will have to make a copy anyway, or modify how the data was originally made.
Examples
assert_eq!(guarded_transmute_pod_many_permissive::<u16>(&[0x00]), Ok([].as_ref()));