scolapasta_path

Function os_str_to_bytes

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

Convert a platform-specific OsStr to a byte slice.

Unsupported platforms fallback to converting through str.

§Examples

let platform_string: &OsStr = OsStr::new("/etc/passwd");
assert_eq!(os_str_to_bytes(platform_string), Ok(&b"/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.