Function safe_transmute::base::transmute_many[][src]

pub unsafe fn transmute_many<T, G: Guard>(
    bytes: &[u8]
) -> Result<&[T], Error<'_, u8, T>>

View a byte slice as a slice of an arbitrary type.

The required byte length of the slice depends on the chosen boundary guard. Please see the Guard API.

Safety

Failure to fulfill any of the requirements above may result in undefined behavior.

Errors

An error is returned if the data does not comply with the policies of the given guard G.

Examples

// Little-endian
unsafe {
    assert_eq!(
        transmute_many::<u16, SingleManyGuard>(&[0x00, 0x01, 0x00, 0x02])?,
        &[0x0100, 0x0200]
    );
}