about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2023-04-16 07:05:54 +0000
committerDeadbeef <ent3rm4n@gmail.com>2023-04-16 07:05:54 +0000
commitddc02b0f321da0e16e4abb4d0515440055c3bbd7 (patch)
tree150195018babf51db858c405b47f59b5381ff720
parentd88f979437299dfda0f5214ec14e809a10e10ff0 (diff)
downloadrust-ddc02b0f321da0e16e4abb4d0515440055c3bbd7.tar.gz
rust-ddc02b0f321da0e16e4abb4d0515440055c3bbd7.zip
hack cstr is_empty
-rw-r--r--library/core/src/ffi/c_str.rs3
1 files changed, 2 insertions, 1 deletions
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.