diff --git a/src/c_str.rs b/src/c_str.rs index 9aa0639776..0f7562d9f0 100644 --- a/src/c_str.rs +++ b/src/c_str.rs @@ -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<'_> {}