scolapasta_path

Function bytes_to_os_str

Source
pub fn bytes_to_os_str(bytes: &[u8]) -> Result<&OsStr, ConvertBytesError>
Expand description

Convert a byte slice to a platform-specific OsStr.

Unsupported platforms fallback to converting through str.

§Examples

let bytes: &[u8] = b"/etc/passwd";
assert_eq!(bytes_to_os_str(bytes), Ok(OsStr::new("/etc/passwd")));

§Errors

On unix-like platforms, this function is infallible.

On Windows, if the given byte slice does not contain valid UTF-8, an error is returned.