devela::_dep::bytemuck

Function try_cast_slice_arc

pub fn try_cast_slice_arc<A, B>(
    input: Arc<[A]>,
) -> Result<Arc<[B]>, (PodCastError, Arc<[A]>)> 
Available on crate feature dep_bytemuck only.
Expand description

Attempts to cast the content type of a Arc<[T]>.

On failure you get back an error along with the starting Arc<[T]>.

The bounds on this function are the same as cast_mut, because a user could call Rc::get_unchecked_mut on the output, which could be observable in the input.

§Failure

  • The start and end content type of the Arc<[T]> must have the exact same alignment.
  • The start and end content size in bytes of the Arc<[T]> must be the exact same.