Function sp_std::str::from_boxed_utf8_unchecked
1.20.0 · source · [−]pub unsafe fn from_boxed_utf8_unchecked(
v: Box<[u8], Global>
) -> Box<str, Global>ⓘimpl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
Expand description
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);