[][src]Function cast_rs::slicecast::cast_mut

pub unsafe fn cast_mut<T, U>(e: &mut [T]) -> &mut [U]

Performs a cast between two mutable slice types.

This is unsafe because there is no guarantee that the resulting slice contains valid data.

The underlying buffer of the given slice must begin at a non-null address, even if the slice itself has a length of zero.

Panics

This function panics if the resulting slice cannot hold the same number of bytes as the original slice.

Example

let mut foo: [u8; 4] = [1, 0, 0, 0];
let bar: &mut [u32] = unsafe { slice_cast::cast_mut(&mut foo) };
println!("{:?}", bar);