[][src]Function posixmq::name_from_bytes

pub fn name_from_bytes<N: AsRef<[u8]> + ?Sized>(name: &N) -> Cow<CStr>

Helper function for converting a str or byte slice into a C string without allocating when possible.

The input is returned as-is if it starts with a '/' and ends with a '\0'. Otherwise a new string is created with those characters included.

The name must not contain interior '\0' bytes.

Panics

If the name contains interior NUL ('\0') bytes it is likely due to a bug, so this function will then panic instead of returning a Result.