[−][src]Function cast_rs::slicecast::cast_to_mut
pub unsafe fn cast_to_mut<T, U>(e: &mut [T]) -> &mut U
Casts a mutable slice to a concrete type.
This is unsafe because there is no guarantee that the resulting type holds 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 size of the resulting type differs from the length in bytes of the original slice.
Example
let mut foo: [u8; 4] = [1, 0, 0, 0]; let bar: &mut u32 = unsafe { slice_cast::cast_to_mut(&mut foo) }; println!("{}", bar);