p3_util

Function convert_vec

Source
pub unsafe fn convert_vec<T, U>(vec: Vec<T>) -> Vec<U>
Expand description

Converts a vector of one type to one of another type.

This is useful to convert between things like Vec<u32> and Vec<[u32; 10]>, for example. This is roughly like a transmutation, except that we also adjust the vector’s length and capacity based on the sizes of the two types.

§Safety

In addition to the usual safety considerations around transmutation, the caller must ensure that the two types have the same alignment, that one of their sizes is a multiple of the other.