Function bytemuck::checked::try_cast_ref
source · pub fn try_cast_ref<A: NoUninit, B: CheckedBitPattern>(
a: &A
) -> Result<&B, CheckedCastError>
Expand description
Try to convert a &T
into &U
.
Failure
- If the reference isn’t aligned in the new type
- If the source type and target type aren’t the same size.
- If
a
contains an invalid bit pattern forB
this fails.