Function artichoke_backend::platform_string::os_string_to_bytes[][src]

pub fn os_string_to_bytes(value: OsString) -> Result<Vec<u8>, ConvertBytesError>
Expand description

Convert a platform-specific OsString to a byte vec.

Unsupported platforms fallback to converting through String.


let platform_string: OsString = OsString::from("/etc/passwd");
assert_eq!(os_string_to_bytes(platform_string), Ok(b"/etc/passwd".to_vec()));


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.