rune::core::object::convert

Function try_from_slice

Source
pub(crate) fn try_from_slice<'brw, 'ob, T, E>(
    slice: &'brw [Gc<ObjectType<'ob>>],
) -> Result<&'brw [Gc<T>], E>
where Gc<T>: TryFrom<Gc<ObjectType<'ob>>, Error = E> + 'ob,
Expand description

This function is required because we have no specialization yet. Essentially this let’s us convert one type to another “in place” without the need to allocate a new slice. We ensure that the two types have the exact same representation, so that no writes actually need to be performed.