Backport count_bytes and is_empty for CStr

This commit is contained in:
Josh Megnauth
2025-07-21 23:47:50 -04:00
parent 6babec246d
commit 57c46f4dd8
+6
View File
@@ -77,6 +77,12 @@ impl<'a> CStr<'a> {
pub fn borrow(string: &'a CString) -> Self {
unsafe { Self::from_ptr(string.as_ptr()) }
}
pub fn count_bytes(&self) -> usize {
self.to_bytes().len()
}
pub fn is_empty(&self) -> bool {
self.count_bytes() == 0
}
}
unsafe impl Send for CStr<'_> {}