pub fn transmute_vec_basic<I: Pod, O: Pod>(
input: Vec<I>,
) -> Result<Vec<O>, (Vec<I>, TransmuteError)>Expand description
If alignment is the same this function is preferred over transmute_vec.
§Errors
- The length of the vector wouldn’t fit the type.
ⓘ
let input: Vec<u8> = vec![1, 2, 3];
let output: Vec<u16, _> = transmute_vec_basic(input).unwrap();- The capacity can’t be converted to units of the output type.
ⓘ
let input: Vec<u8> = Vec::with_capacity(3);
let output: Vec<u16, _> = transmute_vec_basic(input).unwrap();Length, then capacity will be returned.
§ZSTs
- Anything -> ZST
- Keeps length, drops data.
- ZST -> Non ZST
- New Vec from previous allocator.
- Just don’t do this.
§Panics
Panics if the alignment is not the same.
Otherwise this acts exactly the same as transmute_vec.