Function constmuck::cast_slice_alt [−][src]
Expand description
Casts &[T]
to &[U]
Requires both T
and U
to implement Pod
.
Panics
This function panics in the cases where try_cast_slice_alt
returns an error.
Difference with bytemuck
This function has the same differences
with bytemuck::cast_slice
that try_cast_slice_alt
does with
bytemuck::try_cast_slice
.
Example
use constmuck::PodCastError;
use constmuck::{cast_slice_alt, infer};
type Res<T> = Result<T, PodCastError>;
const I8S: &[i8] = cast_slice_alt(&[100u8, 254, 255], infer!());
assert_eq!(*I8S, [100, -2, -1]);