From OsStr
A macro to convert a &OsStr to a more useful types
Dual-licensed under Apache 2.0 or MIT
About
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.
It is most useful in other macros where you don't know the type you are converting to.
Example
use *;
use OsStr;
use Path;
let os_str = new;
let path = try_from_os_str!;
assert_eq!;
let int = try_from_os_str!;
assert_eq!;
Conversion Methods
It will use one of the following traits (in order of preferece) to convert the &OsStr
to the type you want.
- From<&OsStr>
- From<&Path>
- From
- From<&str>
- From
- TryFrom<&OsStr>
- TryFrom<&str>
- FromStr