W3cubDocs

/Rust

Function std::str::from_boxed_utf8_unchecked

pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str>

Converts a boxed slice of bytes to a boxed string slice without checking that the string contains valid UTF-8.

Examples

Basic usage:

let smile_utf8 = Box::new([226, 152, 186]);
let smile = unsafe { std::str::from_boxed_utf8_unchecked(smile_utf8) };

assert_eq!("☺", &*smile);

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/str/fn.from_boxed_utf8_unchecked.html