We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 19d30fc commit ede6dfdCopy full SHA for ede6dfd
src/liballoc/str.rs
@@ -2050,6 +2050,17 @@ impl str {
2050
2051
/// Converts a boxed slice of bytes to a boxed string slice without checking
2052
/// that the string contains valid UTF-8.
2053
+///
2054
+/// # Examples
2055
2056
+/// Basic usage:
2057
2058
+/// ```
2059
+/// let smile_utf8 = Box::new([226, 152, 186]);
2060
+/// let smile = unsafe { std::str::from_boxed_utf8_unchecked(smile_utf8) };
2061
2062
+/// assert_eq!("☺", &*smile);
2063
2064
#[stable(feature = "str_box_extras", since = "1.20.0")]
2065
pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> {
2066
mem::transmute(v)
0 commit comments