From 6d1e8d86cbbd8d053999c5def5a4dd806739baa3 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 11 Oct 2023 23:53:55 -0700 Subject: [PATCH] Cleaner cstr code --- native/src/base/cstr.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/native/src/base/cstr.rs b/native/src/base/cstr.rs index 53d0504b8..0fee8cc71 100644 --- a/native/src/base/cstr.rs +++ b/native/src/base/cstr.rs @@ -568,7 +568,7 @@ macro_rules! impl_str_write { impl<$($g)*> AsMut for $t { #[inline(always)] fn as_mut(&mut self) -> &mut Utf8CStr { - self + self.as_utf8_cstr_mut() } } )*} @@ -597,10 +597,8 @@ macro_rules! impl_str_buf { } #[inline(always)] fn clear(&mut self) { - unsafe { - self.mut_buf()[0] = b'\0'; - self.set_len(0); - } + self.buf[0] = b'\0'; + self.used = 0; } } )*}