devela::_dep::bytemuck::checked

Function try_cast_ref

pub fn try_cast_ref<A, B>(a: &A) -> Result<&B, CheckedCastError> 
Available on crate feature dep_bytemuck only.
Expand description

Try to convert a &A into &B.

§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 for B this fails.