Use str::from_utf8 instead

This commit is contained in:
Christian Poveda 2019-09-12 09:25:39 -05:00
parent ed70617b9c
commit fa20338c9a
2 changed files with 1 additions and 2 deletions

View File

@ -1,4 +1,3 @@
pub mod foreign_items;
pub mod intrinsics;
pub mod tls;

View File

@ -6,7 +6,7 @@ fn main() {
let mut y: Vec<u8> = unsafe { std::mem::transmute(x) };
unsafe { y.set_len(2 * N) };
println!("{:?}", String::from_utf8_lossy(&y));
println!("{:?}", std::str::from_utf8(&y).unwrap());
let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
unsafe { x.set_len(N) };