pub const fn to_str(this: &CStr) -> Result<&str, Utf8Error>
Expand description
Converts this CStr to a string slice, excluding the nul terminator.
Const equivalent of CStr::to_str
§Performance
This function takes linear time to run, proportional to the length of this
.
§Example
use konst::{ffi::cstr, unwrap_ctx};
use std::ffi::CStr;
const CS: &CStr = unwrap_ctx!(cstr::from_bytes_with_nul(b"of beads\0"));
const STRING: &str = unwrap_ctx!(cstr::to_str(CS));
assert_eq!(STRING, "of beads");