Function safe_transmute::base::transmute_vec[][src]

pub unsafe fn transmute_vec<S, T>(vec: Vec<S>) -> Vec<T>

Transform a vector into a vector of another element type.

The vector’s allocated byte buffer (if already allocated) will be reused.

Safety

Vector transmutations are exceptionally dangerous because of the constraints imposed by Vec::from_raw_parts().

Unless all of the following requirements are fulfilled, this operation may result in undefined behavior:

Examples

unsafe {
    assert_eq!(
        transmute_vec::<u8, i8>(vec![0x00, 0x01, 0x00, 0x02]),
        vec![0x00i8, 0x01i8, 0x00i8, 0x02i8]
    );
}