Trait method lrs::string::ToCStr::to_or_as_cstr

Tries to create a CStr without copying and copies if that's not possible.

Syntax

fn to_or_as_cstr(&'a self, buf: &'a mut [u8]) -> Result<&'a CStr, Errno>

Arguments

NameDescription
buf

The buffer in which the CStr will be created if it has to be copied.

Return value

Returns the borrowed or created CStr.

Remarks

For example, "Hello World\0" does not have to be copied. The default implementation simply calls to_cstr.