From 37df39ec37372e8205551e45665ed859a3515445 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 3 Aug 2024 01:52:16 -0700 Subject: [PATCH] Address clippy warnings --- native/src/base/cstr.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/src/base/cstr.rs b/native/src/base/cstr.rs index 145da1852..f2523e72d 100644 --- a/native/src/base/cstr.rs +++ b/native/src/base/cstr.rs @@ -108,7 +108,7 @@ impl StringExt for String { fn nul_terminate(&mut self) -> &mut [u8] { self.reserve(1); // SAFETY: the string is reserved to have enough capacity to fit in the null byte - // SAFETY: the null byte is explicitly added outside of the string's length + // SAFETY: the null byte is explicitly added outside the string's length unsafe { let buf = slice::from_raw_parts_mut(self.as_mut_ptr(), self.len() + 1); *buf.get_unchecked_mut(self.len()) = b'\0'; @@ -122,7 +122,7 @@ impl StringExt for PathBuf { fn nul_terminate(&mut self) -> &mut [u8] { self.reserve(1); // SAFETY: the PathBuf is reserved to have enough capacity to fit in the null byte - // SAFETY: the null byte is explicitly added outside of the PathBuf's length + // SAFETY: the null byte is explicitly added outside the PathBuf's length unsafe { let bytes: &mut [u8] = mem::transmute(self.as_mut_os_str().as_bytes()); let buf = slice::from_raw_parts_mut(bytes.as_mut_ptr(), bytes.len() + 1); @@ -314,7 +314,7 @@ impl Utf8CStr { CStr::from_bytes_with_nul(buf)?; str::from_utf8(buf)?; // Both condition checked - unsafe { Ok(mem::transmute(buf)) } + unsafe { Ok(mem::transmute::<&mut [u8], &mut Utf8CStr>(buf)) } } pub fn from_string(s: &mut String) -> &mut Utf8CStr {