rust/tests/run-pass/aligned_utf8_check.rs
2019-09-11 12:08:42 -05:00

14 lines
309 B
Rust

fn main() {
const N: usize = 10;
let x = vec![0x4141u16; N];
let mut y: Vec<u8> = unsafe { std::mem::transmute(x) };
unsafe { y.set_len(2 * N) };
println!("{:?}", String::from_utf8_lossy(&y));
let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
unsafe { x.set_len(N) };
}