Function artichoke_backend::platform_string::os_str_to_bytes[][src]

pub fn os_str_to_bytes(value: &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.