pub(crate) trait PointerToCStr {
// Required method
unsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>;
}
Expand description
Trait that eases conversions from a char pointer (no matter the signedness, they are used
inconsistently in RIOT) to a CStr. The result is often used with ?.to_str().ok()?
.
Required Methods§
Sourceunsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>
unsafe fn to_lifetimed_cstr<'a>(self) -> Option<&'a CStr>
Cast self around until it is suitable input to core::ffi::CStr::from_ptr()
, and run
that function. See there for safety requirements; in particular, the user needs to ensure
that the lifetime is suitable.
This returns None if self is the null pointer.