Function artichoke_backend::platform_string::bytes_to_os_str
source · [−]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.