diff options
Diffstat (limited to 'src/impls/cstr.rs')
-rw-r--r-- | src/impls/cstr.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/impls/cstr.rs b/src/impls/cstr.rs new file mode 100644 index 0000000..5467963 --- /dev/null +++ b/src/impls/cstr.rs @@ -0,0 +1,18 @@ + +use std::ffi::CStr; +use std::os::raw::c_char; + +use crate::*; + +impl AsLtPtr for CStr { + type Target = c_char; + + /// Returns the inner pointer to this C string. + /// + /// The returned pointer points to a contiguous region of memory terminated + /// with a 0 byte to represent the end of the string. + #[inline] + fn as_lt_ptr(&self) -> ConstLtPtr<'_, c_char> { + unsafe { ConstLtPtr::from_raw(self.as_ptr()) } + } +} |