From ddc02b0f321da0e16e4abb4d0515440055c3bbd7 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sun, 16 Apr 2023 07:05:54 +0000 Subject: [PATCH] hack cstr is_empty --- library/core/src/ffi/c_str.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 4a5306ccaa7..25595328c65 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -536,7 +536,8 @@ impl CStr { pub const fn is_empty(&self) -> bool { // SAFETY: We know there is at least one byte; for empty strings it // is the NUL terminator. - (unsafe { self.inner.get_unchecked(0) }) == &0 + // FIXME(const-hack): use get_unchecked + unsafe { *self.inner.as_ptr() == 0 } } /// Converts this C string to a byte slice.