Function safe_transmute::base::transmute_many_mut[][src]

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

View a mutable 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_mut::<u16, SingleManyGuard>(&mut [0xFF, 0x01, 0x00, 0x02])?,
        &mut [0x01FF, 0x0200]
    );
}