Function bytemuck::checked::try_cast_slice  
source · pub fn try_cast_slice<A: NoUninit, B: CheckedBitPattern>(
    a: &[A]
) -> Result<&[B], CheckedCastError>Expand description
Try to convert &[A] into &[B] (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>()
Failure
- 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.5u32values, so that’s a failure).
- Similarly, you can’t convert between a ZST and a non-ZST.
- If any element of the converted slice would contain an invalid bit pattern
for Bthis fails.