Fixed transmute argument
This commit is contained in:
parent
1767c8bdf0
commit
18377082f1
1 changed files with 1 additions and 1 deletions
|
@ -420,7 +420,7 @@ pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
|
||||||
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 { mem::transmute(self) }
|
unsafe { mem::transmute(v) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a slice of bytes to a string slice without checking
|
/// Converts a slice of bytes to a string slice without checking
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue