]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/aligned_utf8_check.rs
Use str::from_utf8 instead
[rust.git] / tests / run-pass / aligned_utf8_check.rs
1 fn main() {
2     const N: usize = 10;
3
4     let x = vec![0x4141u16; N];
5
6     let mut y: Vec<u8> = unsafe { std::mem::transmute(x) };
7     unsafe { y.set_len(2 * N) };
8
9     println!("{:?}", std::str::from_utf8(&y).unwrap());
10
11     let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
12     unsafe { x.set_len(N) };
13 }