pub fn try_cast_slice<A: Pod, B: Pod>(a: &[A]) -> Result<&[B], PodCastError>
Try to convert
&[U] (possibly with a change in length).
input.as_ptr() as usize == output.as_ptr() as usize
input.len() * size_of::<A>() == output.len() * size_of::<B>()
- If the target type has a greater alignment requirement and the input slice isn't aligned.
- If the target element type is a different size from the current element
type, and the output slice wouldn't be a whole number of elements when
accounting for the size change (eg: 3
u16values is 1.5
u32values, so that's a failure).
- Similarly, you can't convert between a ZST and a non-ZST.