pub const fn to_bytes_with_nul(this: &CStr) -> &[u8]
Expand description
Converts this CStr to a byte slice, including the nul terminator.
Const equivalent of CStr::to_bytes_with_nul
§Performance
This function takes linear time to run, proportional to the length of this
.
§Const stabilization
The equivalent std function was const-stabilized in Rust 1.72.0.
§Example
use konst::{ffi::cstr, unwrap_ctx};
use std::ffi::CStr;
const CS: &CStr = unwrap_ctx!(cstr::from_bytes_with_nul(b"example\0"));
const BYTES: &[u8] = cstr::to_bytes_with_nul(CS);
assert_eq!(BYTES, b"example\0");