Skip to content

Commit

Permalink
Made formatting consistent with surrounding code
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrimati1992 committed Aug 6, 2020
1 parent 748b0c3 commit 77d0d15
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions library/core/src/str/mod.rs
Expand Up @@ -381,15 +381,12 @@ pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
Ok(unsafe { from_utf8_unchecked_mut(v) })
}


#[repr(C)]
union StrOrSlice<'a> {
str: &'a str,
slice: &'a [u8],
}



/// Converts a slice of bytes to a string slice without checking
/// that the string contains valid UTF-8.
///
Expand Down Expand Up @@ -429,10 +426,9 @@ union StrOrSlice<'a> {
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
// SAFETY: the caller must guarantee that the bytes `v` are valid UTF-8.
// 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
/// that the string contains valid UTF-8; mutable version.
///
Expand Down

0 comments on commit 77d0d15

Please sign in to comment.