Function artichoke_backend::platform_string::bytes_to_os_str[][src]

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

Convert a byte slice to a platform-specific OsStr.

Unsupported platforms fallback to converting through str.


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


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.