pub const fn from_bytes_until_nul(
bytes: &[u8],
) -> Result<&CStr, FromBytesUntilNulError>
Expand description
Converts a byte slice which contains any amount of nul bytes into a &CStr
.
Const equivalent of CStr::from_bytes_until_nul
§Const stabilization
The equivalent std function was const-stabilized in Rust 1.69.0.
§Example
use konst::{ffi::cstr, unwrap_ctx};
use std::ffi::CStr;
const CS: &CStr = unwrap_ctx!(cstr::from_bytes_until_nul(b"hello\0world"));
assert_eq!(CS.to_str().unwrap(), "hello");