bytemuck::allocation

Function try_from_box_bytes

Source
pub fn try_from_box_bytes<T: FromBoxBytes + ?Sized>(
    input: BoxBytes,
) -> Result<Box<T>, (PodCastError, BoxBytes)>
Expand description

Re-interprets BoxBytes as Box<T>.

T must be either Sized + AnyBitPattern, or [U] where U: AnyBitPattern.

Returns Err:

  • If the input isn’t aligned for T.
  • If T: Sized and the input’s length isn’t exactly the size of T.
  • If T = [U] and the input’s length isn’t exactly a multiple of the size of U.