Crate slice_cast [] [src]

Support for casting between slice types.

This Rust crate provides support for performing cast operations on slices.

The cast() and cast_mut() functions perform casts between slice types:

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

The cast_to() and cast_to_mut() functions perform casts from slices into concrete types:

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

Functions

cast

Performs a cast between two immutable slice types.

cast_mut

Performs a cast between two mutable slice types.

cast_to

Casts an immutable slice to a concrete type.

cast_to_mut

Casts a mutable slice to a concrete type.