mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
hack cstr is_empty
This commit is contained in:
parent
d88f979437
commit
ddc02b0f32
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user