Expand description

A macro for trying to convert an &OsStr to another more usefull type There are lots of ways to do that and this will pick the best via autoref based specialization e.g. a PathBuf will be created via From<OsString> not From<String> so non UTF8 paths will work.

use from_os_str::*;
use std::ffi::OsStr;
use std::path::Path;
let os_str = OsStr::new("123");
let path = try_from_os_str!(os_str as &Path);
assert_eq!(path, Ok(Path::new("123")));
let int = try_from_os_str!(os_str as u8);
assert_eq!(int, Ok(123));

Macros

Convert an &OsStr to another more usefull type There are lots of ways to do that and this will pick the best via autoref based specialization e.g. a PathBuf will becreated via From<OsString> not From<String> so non UTF8 paths will work.

Enums

An error that can occure when converting an OsString to another type It can either be a problem converting the bytes passed into the OsStr as a valid UTF8 string or an error parsing the string