optional_cstr_to_str

Function optional_cstr_to_str 

Source
pub unsafe fn optional_cstr_to_str<'a>(ptr: *const c_char) -> Option<&'a str>
Expand description

Convert an optional C string pointer into Option<&str>.

§Safety

  • Assumes ptr is a valid, null-terminated UTF-8 C string pointer or NULL.
  • Any borrowed string must not outlive the underlying allocation.

§Panics

Panics if ptr is not null but contains invalid UTF-8.