hack cstr is_empty

This commit is contained in:
Deadbeef 2023-04-16 07:05:54 +00:00
parent d88f979437
commit ddc02b0f32

View file

@ -536,7 +536,8 @@ pub const fn as_ptr(&self) -> *const c_char {
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.