Made formatting consistent with surrounding code
This commit is contained in:
parent
748b0c37a9
commit
77d0d152cc
1 changed files with 1 additions and 5 deletions
|
@ -381,15 +381,12 @@ pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
||||||
Ok(unsafe { from_utf8_unchecked_mut(v) })
|
Ok(unsafe { from_utf8_unchecked_mut(v) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
union StrOrSlice<'a> {
|
union StrOrSlice<'a> {
|
||||||
str: &'a str,
|
str: &'a str,
|
||||||
slice: &'a [u8],
|
slice: &'a [u8],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Converts a slice of bytes to a string slice without checking
|
/// Converts a slice of bytes to a string slice without checking
|
||||||
/// that the string contains valid UTF-8.
|
/// that the string contains valid UTF-8.
|
||||||
///
|
///
|
||||||
|
@ -429,10 +426,9 @@ union StrOrSlice<'a> {
|
||||||
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
|
||||||
// SAFETY: the caller must guarantee that the bytes `v` are valid UTF-8.
|
// SAFETY: the caller must guarantee that the bytes `v` are valid UTF-8.
|
||||||
// Also relies on `&str` and `&[u8]` having the same layout.
|
// Also relies on `&str` and `&[u8]` having the same layout.
|
||||||
unsafe{ StrOrSlice{ slice: v }.str }
|
unsafe { StrOrSlice { slice: v }.str }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Converts a slice of bytes to a string slice without checking
|
/// Converts a slice of bytes to a string slice without checking
|
||||||
/// that the string contains valid UTF-8; mutable version.
|
/// that the string contains valid UTF-8; mutable version.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue