bytes_with_null

Function bytes_with_null 

Source
fn bytes_with_null(bytes: &[u8]) -> Cow<'_, CStr>
Expand description

Converts a byte slice into a null-terminated CStr.

Returns a borrowed CStr if the slice already contains a null byte; otherwise, returns an owned CStr with a null byte appended.

§Returns

A [Cow<’_, CStr>] containing a guaranteed null-terminated string.