We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f90eabd + ede6dfd commit 38a8d60Copy full SHA for 38a8d60
src/liballoc/str.rs
@@ -2061,6 +2061,17 @@ impl str {
2061
2062
/// Converts a boxed slice of bytes to a boxed string slice without checking
2063
/// that the string contains valid UTF-8.
2064
+///
2065
+/// # Examples
2066
2067
+/// Basic usage:
2068
2069
+/// ```
2070
+/// let smile_utf8 = Box::new([226, 152, 186]);
2071
+/// let smile = unsafe { std::str::from_boxed_utf8_unchecked(smile_utf8) };
2072
2073
+/// assert_eq!("☺", &*smile);
2074
2075
#[stable(feature = "str_box_extras", since = "1.20.0")]
2076
pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> {
2077
mem::transmute(v)
0 commit comments