mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-12 07:43:31 +00:00
parent
19d30fcdb2
commit
ede6dfd72a
@ -2050,6 +2050,17 @@ impl str {
|
|||||||
|
|
||||||
/// Converts a boxed slice of bytes to a boxed string slice without checking
|
/// Converts a boxed slice of bytes to a boxed string slice without checking
|
||||||
/// that the string contains valid UTF-8.
|
/// 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);
|
||||||
|
/// ```
|
||||||
#[stable(feature = "str_box_extras", since = "1.20.0")]
|
#[stable(feature = "str_box_extras", since = "1.20.0")]
|
||||||
pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> {
|
pub unsafe fn from_boxed_utf8_unchecked(v: Box<[u8]>) -> Box<str> {
|
||||||
mem::transmute(v)
|
mem::transmute(v)
|
||||||
|
Loading…
Reference in New Issue
Block a user