diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2023-04-16 07:05:54 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2023-04-16 07:05:54 +0000 |
| commit | ddc02b0f321da0e16e4abb4d0515440055c3bbd7 (patch) | |
| tree | 150195018babf51db858c405b47f59b5381ff720 | |
| parent | d88f979437299dfda0f5214ec14e809a10e10ff0 (diff) | |
| download | rust-ddc02b0f321da0e16e4abb4d0515440055c3bbd7.tar.gz rust-ddc02b0f321da0e16e4abb4d0515440055c3bbd7.zip | |
hack cstr is_empty
| -rw-r--r-- | library/core/src/ffi/c_str.rs | 3 |
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. |
